Sunday, 29 April 2018

Dot Liquid Template Implementation in C# and MVC

Dot Liquid Template Implementation in C# and MVC

Step 1: Install Dot Liquid dll using Nuget.
Step 2: Create an Abstract class with Hash abstract method present in it "GetFromAnonymousObject()".


Step 3:Create a Model that has all the required set of properties used as template tags and inherit with "ILiquidizable" and "TemplateBaseModel" class also implement the "GetFromAnonymousObject()"  and "ToLiquid()" methods.



Step 4: Implement the hash functions in the category and Tags model has well.



Step 5 :Create a Custom TagModel with set of properties.                                 

Step 6: Insert the Custom tags to the Custom tag table.

Step 7: Create a controller and View page with create, edit and delete action methods in it.

Step 8: Implementation of save and dot liquid preview content template.
  •  Validate the content by
    • checking all the required feilds entered.
    • parse and validate that invalid tags are not entered other than custom tags.
    • Parse and validate invalid format tags are not entered.
  • Save the template content , if validation is successfull, if not display the validation message.
  • Create an object of the derived class and set the content values of all the property fields that are used for custom tags content replacement.
  • Format the content by applying the template content with object set value above and replace all the tags with actual info content using dot liquid and return the preview string.
  • Display the preview content in the view.





Step 9: Implement view and JS side chnages.