dotliquid

Dotliquid cannot bind property of an object inside an array

▼魔方 西西 提交于 2021-02-11 12:47:30
问题 I have a .NET Core application that is using dotliquid. From the try online it looks like I can bind a property of an object that is inside an array. Like {{user.tasks[0].name}} where tasks is a collection of task object and name is property of the task . I have JSON model that would be the input to the template. I don't know the JSON structure during the design time. So I am converting JSON string into ExpandoObject . However, this does not work when I bind property of an object that is

how to use split and replace in same expression in liquid json transformation?

本秂侑毒 提交于 2020-04-18 12:33:17
问题 input string - {"testData":"jack%2C LLC,ville%2C LLC,Nav LLC,50 New Hope%2C LLC,"} expected output {"output":"<Value>jack, LLC</Value><Value>ville, LLC</Value><Value>Nav LLC</Value><Value>50 New Hope, LLC</Value>"} for conversion using this - %2C is converted to , comma after converting into value tags so that it does not interfare with the delimiter comma. I tried like below expression {% "output": "<Value>{{ demo | Split: ',' | Last }}</Value>", %} But need to use replace first to replace

how to use split and replace in same expression in liquid json transformation?

左心房为你撑大大i 提交于 2020-04-18 12:32:49
问题 input string - {"testData":"jack%2C LLC,ville%2C LLC,Nav LLC,50 New Hope%2C LLC,"} expected output {"output":"<Value>jack, LLC</Value><Value>ville, LLC</Value><Value>Nav LLC</Value><Value>50 New Hope, LLC</Value>"} for conversion using this - %2C is converted to , comma after converting into value tags so that it does not interfare with the delimiter comma. I tried like below expression {% "output": "<Value>{{ demo | Split: ',' | Last }}</Value>", %} But need to use replace first to replace

Try to use DotLiquid with c#

我的梦境 提交于 2020-01-14 03:31:06
问题 I was unable to excute example in : http://dotliquidmarkup.org/try-online with C#. I have the same example and try to execute it with following code : var template = DotLiquid.Template.Parse(myTemplate); Message.Body = template.Render(DotLiquid.Hash.FromAnonymousObject(user)); Where myTemplate is exactly the same as in example : <p>{{ user.name | upcase }} has to do:</p> <ul> {% for item in user.tasks -%} <li>{{ item.name }}</li> {% endfor -%} </ul> But when hit Render i receive error : An

DotLiquid, some beginner questions/observations

瘦欲@ 提交于 2019-12-11 06:08:23
问题 I'm investigating using dotliquid to replace a home grown piece of templating code and I'm wondering about the best way to achieve my goal. The old code used to use sigils in the template and, together with a Dictionary, used regexes to search and replace. So you did something like this in the template file: Specific error: {#ErrorId#} Error description: {#Description#} Additional information:{#AdditionalInformation#} And in the C# code: Dictionary<string, string> tokensAndValues = new

DotLiquid/Liquid access to dictionary

家住魔仙堡 提交于 2019-12-05 01:06:00
问题 I am using DotLiquid template engine and trying access dictionary value in template. I have passed to template this drop: public class SomeDrop : Drop { public Dictionary<string, object> MyDictionary {get; set;} } var someDropInstance = SomeDrop { MyDictionary = new Dictionary<string, object> {{"myKey", 1}} } Template.NamingConvention = new CSharpNamingConvention(); var preparedTemplate = Template.Parse(template); var templateOutput = preparedTemplate.Render(Hash.FromAnonymousObject(new {

DotLiquid/Liquid access to dictionary

泪湿孤枕 提交于 2019-12-03 16:34:18
I am using DotLiquid template engine and trying access dictionary value in template. I have passed to template this drop: public class SomeDrop : Drop { public Dictionary<string, object> MyDictionary {get; set;} } var someDropInstance = SomeDrop { MyDictionary = new Dictionary<string, object> {{"myKey", 1}} } Template.NamingConvention = new CSharpNamingConvention(); var preparedTemplate = Template.Parse(template); var templateOutput = preparedTemplate.Render(Hash.FromAnonymousObject(new { @this = someDropInstance })); In template i can't access to myKey value as {{ this.MyDictionary.myKey }}