private Template CreateNewDotLiquidTemplate(string inputTemplate) { // Remove custom comments from the source, but make no other changes because we are using the RockLiquid framework. var converter = new LavaToLiquidTemplateConverter(); var liquidTemplate = converter.RemoveLavaComments(inputTemplate); var template = Template.Parse(liquidTemplate); /* * 2/19/2020 - JPH * The DotLiquid library's Template object was not originally designed to be thread safe, but a PR has since * been merged into that repository to add this functionality (https://github.com/dotliquid/dotliquid/pull/220). * We have cherry-picked the PR's changes into our DotLiquid project, allowing the Template to operate safely * in a multithreaded context, which can happen often with our cached Template instances. * * Reason: Rock Issue #4084, Weird Behavior with Lava Includes */ template.MakeThreadSafe(); return(template); }
/// <summary> /// Pre-parses a Lava template to ensure it is using Liquid-compliant syntax, and creates a new template object. /// </summary> /// <param name="lavaTemplate"></param> /// <param name=""></param> /// <returns></returns> private FluidTemplate CreateNewFluidTemplate(string lavaTemplate, out string liquidTemplate) { FluidTemplate template; liquidTemplate = _lavaToLiquidConverter.RemoveLavaComments(lavaTemplate); string error; IFluidTemplate fluidTemplate; var success = _parser.TryParse(liquidTemplate, out fluidTemplate, out error); var fluidTemplateObject = ( FluidTemplate )fluidTemplate; if (success) { template = new FluidTemplate(new List <Statement>(fluidTemplateObject.Statements)); } else { throw new LavaParseException(this.EngineName, liquidTemplate, error); } return(template); }