/// <summary> /// Creates a new render context instance. /// </summary> /// <param name="mergeFields"></param> /// <param name="enabledCommands"></param> /// <returns></returns> public static ILavaRenderContext NewRenderContext(ILavaDataDictionary mergeFields, IEnumerable <string> enabledCommands = null) { if (_engine == null) { return(null); } return(_engine.NewRenderContext(mergeFields, enabledCommands)); }
/// <summary> /// Sets the user-defined variables in the current context that are internally available to custom filters and tags. /// </summary> /// <param name="fieldValues"></param> public void SetMergeFields(ILavaDataDictionary fieldValues) { if (fieldValues == null) { return; } foreach (var key in fieldValues.AvailableKeys) { SetMergeField(key, fieldValues.GetValue(key)); } }
/// <summary> /// Render the provided template in a new context with the specified merge fields. /// </summary> /// <param name="inputTemplate"></param> /// <param name="mergeFields">The collection of merge fields to be added to the context used to render the template.</param> /// <returns> /// The rendered output of the template. /// If the template is invalid, returns an error message or an empty string according to the current ExceptionHandlingStrategy setting. /// </returns> public static LavaRenderResult RenderTemplate(ILavaTemplate inputTemplate, ILavaDataDictionary mergeFields) { var result = RenderTemplate(inputTemplate, LavaRenderParameters.WithContext(_engine.NewRenderContext(mergeFields))); return(result); }
/// <summary> /// Sets a collection of named values for internal use only. /// Internal values are not available to be resolved in the Lava Template. /// </summary> /// <param name="values"></param> public void SetInternalFields(ILavaDataDictionary values) { SetInternalFields(values as IDictionary <string, object>); }
/// <summary> /// Create a new template context and add the specified merge fields. /// </summary> /// <param name="mergeFields"></param> /// <returns></returns> public ILavaRenderContext NewRenderContext(ILavaDataDictionary mergeFields, IEnumerable <string> enabledCommands = null) { return(NewRenderContextInternal(mergeFields, enabledCommands)); }
public DotLiquidLavaDataDictionaryProxy(ILavaDataDictionary dataObject) { _dataObject = dataObject; }