What is the use of tokens in dotliquid Tag

26 views
Skip to first unread message

Laksh Parab

unread,
May 6, 2019, 6:41:28 PM5/6/19
to dotliquid
In dotliquid we can create custom tag like below

public class Random : DotLiquid.Tag
{
    private int _max;

    public override void Initialize(string tagName, string markup, List<string> tokens)
    {
        base.Initialize(tagName, markup, tokens);
        _max = Convert.ToInt32(markup);
    }

    public override void Render(Context context, TextWriter result)
    {
        result.Write(new Random().Next(_max).ToString());
    }
}
The initialize method takes tokens as 3rd parameter. What is the use of tokens parameter and how they are being passed to the Initialize method from the template?



Reply all
Reply to author
Forward
0 new messages