I have just started using Client Dependency with Web Forms - a bit behind the times, but definitely appreciate the functionality.
Now I decide to try my hand at MVC for Umbraco, and want to utilise Client Dependency, but so far without success.
I now have 2 issues: Firstly and most importantly, how to get Client Dependency working - current code provided below:
Secondly, within web forms I had 2 sets of Client Dependency code - one set in the head and one set at the end of the page for speed optimisation. Is this achieveable within MVC ?
And so onto my code - this is what I have in my Master.cshtml view page
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using ClientDependency.Core @using ClientDependency.Core.Mvc @{ Layout = null; Html.RequiresCss("/css/base.css", "Styles").RequiresCss("/css/skeleton.css", "Styles").RequiresCss("layout.css", "Styles").RequiresJs("/scripts/jquery-1.9.1.min.js"); var homepage = Model.Content.AncestorOrSelf(1); } ... Other code here ...
@Html.Raw(Html.RenderCssHere())
@Html.Raw(Html.RenderJsHere())
With v1.7.0.3 you dont need to do the @Html.Raw around the renderers anymore which is nice. Also note that the config examples shipped with Umbraco are not 100% correct but are going to be fixed in a future release.
So to get multiple locations you need to update the clientdependency.config file to have a custom renderer for the other locations.
Towards the bottom of the file there is a commented section that you will need to uncomment.
And thats it! You should now be able to create as many Renderers as you need. Shannon has created feature request for in the future to not have to specify any configuration and to make it easy to just create new Renderer sections by providing a string key.
MVC and Client Dependency in V4.11.5
Hi there
I have just started using Client Dependency with Web Forms - a bit behind the times, but definitely appreciate the functionality.
Now I decide to try my hand at MVC for Umbraco, and want to utilise Client Dependency, but so far without success.
I now have 2 issues:
Firstly and most importantly, how to get Client Dependency working - current code provided below:
Secondly, within web forms I had 2 sets of Client Dependency code - one set in the head and one set at the end of the page for speed optimisation. Is this achieveable within MVC ?
And so onto my code - this is what I have in my Master.cshtml view page
I downloaded and added the Mvc dll file from http://clientdependency.codeplex.com/ and placed it in the bin.
The HTML output is simply some comments as below:
Can anyone assist please ?
Thanks, nigel
Im after the same info regarding specifying multiple render locations. I am also getting the strange output.
<!--[Css:Name="StandardRenderer"]//-->
With a whole bunch of help from Shannon and upgrading to v1.7.0.3 https://nuget.org/packages/ClientDependency-Mvc/1.7.0.3 I was about to get the CDF working the way that I wanted in 6.1.1
With v1.7.0.3 you dont need to do the @Html.Raw around the renderers anymore which is nice. Also note that the config examples shipped with Umbraco are not 100% correct but are going to be fixed in a future release.
So to get multiple locations you need to update the clientdependency.config file to have a custom renderer for the other locations.
Towards the bottom of the file there is a commented section that you will need to uncomment.
The standardRenderer is the one that ships by default and is what is used for @Html.RenderJsHere() and @Html.RenderCssHere()
The HeadRenderer is my custom one that allows me to create a new renderer for Js and Css somewhere else in my layouts.
So to use this you will need to say where you want your scripts by doing this.
Just specify the renderer that you want to use as a string matching your config.
Then when you want to inject something into that Renderer do the following
And thats it! You should now be able to create as many Renderers as you need. Shannon has created feature request for in the future to not have to specify any configuration and to make it easy to just create new Renderer sections by providing a string key.
Docs for CDF can be found here https://github.com/Shandem/ClientDependency/wiki
Information on config can be found here https://github.com/Shandem/ClientDependency/wiki/Configuration
Information on forcuing providers and renderers can be found here https://github.com/Shandem/ClientDependency/wiki/Forced-Providers
is working on a reply...