Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • webmonger 130 posts 285 karma points
    Feb 07, 2013 @ 15:14
    webmonger
    0

    CdLoader in Umbraco 6 with ClientDependency

    Hi I'm trying to implement CdLoader in Umbraco 6 and when I add the CdLoader Marco to a page with Debug = false the marco errors with the following error.

    ArgumentNullException was unhandeled

    Value cannot be null.
    Parameter name: virtualPath

    It's at the following stage in the file:

    renderer.RegisterDependencies(allDependencies, paths, out jsOutput, out cssOutput, Context);

    The full razor file cobeled together from a few form posts

    @*
    This class will help you to load all scripts and stylesheets using ClientDependency
    Parameters:
    CssPaths (string) Pipe-separated css. The order how you put them is important
    LessPaths (string) Pipe-separated less. The order how you put them is important
    JsPaths (string) Pipe-separated js
    IncludeDefaultPaths (bool, default false) If true, it will prepend ~/css, ~/less and ~/scripts
    *@
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using ClientDependency.Core
    @using ClientDependency.Core.Controls
    @{
    var cssPaths = Parameter.CssPaths;
    var lessPaths = Parameter.LessPaths;
    var jsPaths = Parameter.JsPaths;
    bool includeDefaultPaths;
    bool.TryParse(Parameter.IncludeDefaultPaths, out includeDefaultPaths);
    CdObjects cdPaths = GetClientDependencyPaths(cssPaths, lessPaths, jsPaths, includeDefaultPaths);
    @Html.Raw(cdPaths.Styles)
    @Html.Raw(cdPaths.Scripts)
    }
    @functions
    {
    CdObjects GetClientDependencyPaths(string cssPaths, string lessPaths, string jsPaths, bool includeDefaultPaths)
    {
    var paths = new HashSet<IClientDependencyPath>
    {
    new ClientDependencyPath {Name = "Styles", Path = "~/css"},
    new ClientDependencyPath {Name = "Less", Path = "~/less"},
    new ClientDependencyPath {Name = "Scripts", Path = "~/scripts"}
    };
    var allDependencies = new List<IClientDependencyFile>();
    string cssOutput = "";
    string jsOutput = "";
    int priority = 0;
    if (!string.IsNullOrEmpty(cssPaths))
    {
    allDependencies.AddRange(cssPaths.Split('|').Select(path => new CssInclude { PathNameAlias = includeDefaultPaths ? "Styles" : string.Empty, FilePath = path, Priority = priority++ }));
    }
    if (!string.IsNullOrEmpty(lessPaths))
    {
    allDependencies.AddRange(lessPaths.Split('|').Select(path => new CssInclude { PathNameAlias = includeDefaultPaths ? "Less" : string.Empty, FilePath = path, Priority = priority++ }));
    }
    if (!string.IsNullOrEmpty(jsPaths))
    {
    priority = 0;
    allDependencies.AddRange(jsPaths.Split('|').Select(path => new JsInclude { PathNameAlias = includeDefaultPaths ? "Scripts" : string.Empty, FilePath = path, Priority = priority++ }));
    }
    var renderer = new ClientDependency.Core.FileRegistration.Providers.StandardRenderer();
    renderer.RegisterDependencies(allDependencies, paths, out jsOutput, out cssOutput, Context);
    return new CdObjects { Styles = cssOutput, Scripts = jsOutput };
    }
    class CdObjects
    {
    public string Styles { get; set; }
    public string Scripts { get; set; }
    }
    }

    Any ideas as to why it's unable to output the files correctly?

  • Ioannis Gkoutsidis 16 posts 67 karma points
    Feb 10, 2013 @ 19:56
    Ioannis Gkoutsidis
    0

    Hi webmonger,

    I've already tried to implement CDLoader to a 4.8.0 & 4.9.0 installations, as you did, with no luck.

    I finally decided to use Combres, which from what I've seen so far, is a little easier to implement than ClientDependency, and in less than 2 hours it has been deployed in a 4.11.4 installation as well as in a 6.0.0 one, with no problem!

  • webmonger 130 posts 285 karma points
    Feb 12, 2013 @ 10:32
    webmonger
    0

    Hi Ioannis

    Thanks for your input. I ended up including System.Web.Optimization and using the standard Bundling.

    Jon

Please Sign in or register to post replies

Write your reply to:

Draft