Search code examples
stringdotliquid

Dotliquid: value from string


Is there a way to get the value from a string?

For example:

"SomeString" has the value "Edward".

Input:

{% assign variable = 'SomeString' %}

{{ variable }}

Output:

SomeString

Note: SomeString is a constructed string during runtime, so I in fact need to get the value from a string --> I can't remove the quotes in the assignment.


Solution

  • There is nothing in DotLiquid which allows to do that, however it is always possible to create your own Tag or to build the template at run time.

    public sealed class RuntimeAssign : Tag
    {
         ...
    }
    
    
    Template.RegisterTag<RuntimeAssign>("runtimeassign");