Giter Site home page Giter Site logo

dotliquid's Introduction

DotLiquid

DotLiquid tag on Stack Overflow AppVeyor build codecov NuGet Gitter

Maintainers wanted

Have you sent a PR to this repository? In that case, would you consider getting in touch with me so I can give you commit access to this repository? Please ping me at gitter/dotliquid or here on github.

What is this?

DotLiquid is a .Net port of the popular Ruby Liquid templating language. It is a separate project that aims to retain the same template syntax as the original, while using .NET coding conventions where possible.

For more information about the original Liquid project, see https://shopify.github.io/liquid/.

Quick start

  1. Download the latest release from NuGet.
  2. Read the docs for information on writing and using DotLiquid templates.

Why should I use DotLiquid?

  • You want to leave business logic in your compiled controllers and out of your templates.
  • You're looking for a logic-less template language that also exists for other platforms (ie: node, python).
  • You want to allow your users to edit their own page templates, but want to ensure they don't run insecure code.
  • You want to render templates directly from the database.
  • You want a template engine for emails.

What does it look like?

<ul id="products">
  {% for product in products %}
    <li>
      <h2>{{product.name}}</h2>
      Only {{product.price | price }}

      {{product.description | prettyprint | paragraph }}
    </li>
  {% endfor %}
</ul>

How to use DotLiquid

DotLiquid supports a very simple API based around the DotLiquid.Template class. Generally, you can read the contents of a file into a template, and then render the template by passing it parameters in the form of a Hash object. There are several ways you can construct a Hash object, including from a Dictionary, or using the Hash.FromAnonymousObject method.

Template template = Template.Parse("hi {{name}}"); // Parses and compiles the template
template.Render(Hash.FromAnonymousObject(new { name = "tobi" })); // => "hi tobi"

Projects using DotLiquid

Are you using DotLiquid in an open source project? Tell us with a PR!

dotliquid's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotliquid's Issues

Support layout tag

1/ folder structure:

home.lq
layout/default.lq

2/ home.lq
layout 'default'
this is home content

3/ default.lq
this is from default layout

4/ results

this is from default layout
this is home content

Won't output integer properties of a class

When I use my UserModel and render my template and try to output the ID property, nothing is shown.

using DotLiquid;

namespace tinyweb.framework.tests
{
    public class UserModel : Drop
   {
       public int ID { get; set; }
       public string Username { get; set; }
   }
}

And the template

<h1>{{ model.id }}</h1>

However if I use the following

<h1>{{ model.username }}</h1>

Then the correct username is outputted. Am I doing something wrong or will it not output int properties in a template?

EDIT:

It seems to work when the property is named Id, however niether UserID nor UserId work either. Does anyone have any examples of objects using int properties and DotLiquid?

standard filters return value when null input

Hi,
some filters actually returns an empty string when a null input string is found, while others returns null which seems to me much more correct... any thoughts before I start standardizing them to null?

Support .NET 3.5

We have had a request to support .NET 3.5. I plan to first check that this will not involve too many code changes, and then implement this. One option is to "freeze" the .NET 3.5 version and only update the .NET 4.0 version going forward.

DotLiquid.Tag.If NodeList

I think I've discovered a bug? Maybe it's intentional?

Using version 1.5 (from the downloads page here at github)
If you cast a DotLiquid.Tag.If to DotLiquid.Tag so you can access it's NodeList property, it appears the NodeList only contains nodes after the 'else' part of the tag block. I was expecting it to contain all children of the tag block.

Allow Variable to have global Pre/Post filter

It would be nice to have Pre/Post global filters registered statically to the Variable tag

For instance, I'd like to HtlmEncode every output using a "Post" filter, so I would prevent any XSS atack

Hash.FromAnonymousObject ignores ILiquidizable implementation

Hi,

I'm not sure if I'm using Hash.FromAnonymousObject incorrectly or if there is a more "correct" way of accomplishing this, but the behavior is not working as expected.

I have the following classes defined:

public class MyModel : ILiquidizable
{
  public virtual string FirstName { get; set; }
  public virtual string LastName { get; set; }
  public virtual DateTime StartDate { get; set; }

  public virtual object ToLiquid()
  {
    return new
    {
      FirstName,
      LastName,
      FullName = (FirstName + " " + LastName).Trim(),
      StartDate = StartDate.ToString("yyyy-MM-dd")
    };
  }
}


[TestFixture]
public class ToLiquidTest
{
  [Test]
  public void ShouldUsILiquidForObjectRepresentation()
  {
    var data = new MyModel
    {
      FirstName = "Lorem",
      LastName = "ipsum",
      StartDate = DateTime.Now
    };

    var template = Template.Parse("First Name: {{ Model.FirstName }}\nLast Name: {{ Model.LastName }}\nFull Name: {{ Model.FullName }}\nDate: {{ Model.StartDate }}");

    var model = Hash.FromAnonymousObject(new { });
    model.Add("Model", Hash.FromAnonymousObject(data));

    var result = template.Render(model);

    result.Should().Equal("First Name: Lorem\nLast Name: ipsum\nFull Name: Lorem ipsum\nDate: " + DateTime.Now.ToString("yyyy-MM-dd"));
  }
}

Running the test yields the following:
Expected:

First Name: Lorem
Last Name: ipsum
Full Name: Lorem ipsum
Date: 2011-04-18

Actual:

First Name: Lorem
Last Name: ipsum
Full Name: 
Date: 4/18/2011 1:46:59 PM

Note: I need to have ToLiquid be virtual because of proxy support with NHibernate

ILiquidizable Issue

Given the following class:

public class Post : Document<Post>, ILiquidizable
{
    public string Slug { get; set; }
    public DateTime DatePublished { get; set; }
    public string Title { get; set; }
    public string Entry { get; set; }

    public List<Comment> Comments { get; set; }

    public Post()
    {
        Comments = new List<Comment>();
    }

    object ILiquidizable.ToLiquid()
    {
        return this;
    }
}

When I render a template with this assigned to a "model", it will render the page, but any values outputted will be blank.

This is the rendering code: https://gist.github.com/878516
This is the template code: https://gist.github.com/878504

When registering a type with RegisterSafeType and using a property of that type, ToString should be used when no sub-properties are used.

Example: I used RegisterSafeType on Guid. I don't want to use any sub-properties of Guid, so I register it like this: DotLiquid.Template.RegisterSafeType(typeof(Guid), new string[] { }); As a result, when I use {{SomeVariable.MyGuid}} (as opposed to {{SomeVariable.MyGuid.SomeProperty}}) it should call the ToString() method to output the value. Currently, nothing is written to the template.

Without registering the Guid as a safetype, I get a template error.

Nested Template Inheritance Not Working For Blocks Defined Above Parent

I found another bug with nested template inheritance - this time for content in blocks that are defined in parent templates above the one the current template directly extends. It appears as though the current template only recognizes blocks from the immediately extended template and none that template extends from (I.e., more than one level up). For example, consider the following three templates:

Outer:
{% block start %}{% endblock %} A {% block outer %}{% endblock %} Z

Middle:
{% extends "Outer" %}
{% block outer %} B {% block middle %}{% endblock %} Y {% endblock %}

Inner:
{% extends "Middle" %}
{% block start %} ! {% endblock %}

The expected output should be "! A B Y Z" but instead this outputs "A B Y Z !".

System.Web reference not really needed in .NET 4

Hi,
In StandardFilers.cs a reference to System.Web is used and the method HttpUtility.HtmlEncode() is called in Escape(). In .NET 4 that method (when a string is passed in) just ends up calling System.Net.WebUtility.HtmlEncode(). Using the System.Net method instead of the System.Web one means you can remove the System.Web reference for .NET 4 builds.

if evaluation issue

I was trying to evaluate below template:

{% assign x=1 %}{% if (x>2) %}A{% else %}B{% endif %}
{% assign y=3 %}{% if (y>2) %}A{% else %}B{% endif %}

The answer was:
B
B

but I would expect:
B
A

Default operators fail with double/decimal values

The following test fails with the message "Liquid error: Object must be of type Decimal.":

[Test]
public void TestLessThanDecimal()
{
  var model = new { value = new decimal(-10.5) };

  string output = Template.Parse("{% if model.value < 0 %}passed{% endif %}")
    .Render(Hash.FromAnonymousObject(new {model}));

  Assert.AreEqual("passed", output);
}

Feature Request: Add .Any() filter to collections or additional documentation about linq extensions

Hi,

I was expecting that I could use linq extensions for collections in liquid markup, but they are not supported syntax. Would it make sense to add a few linq extensions as liquid filters?

Thinking about this more, maybe adding the .Any() filter isn't the best approach. It might be confusing to some people that one or two linq extensions are available while the rest wouldn't be supported. Maybe a better approach would be to just add some documentation to the wiki outlining that linq extensions aren't supported for collections and possibly provide the equivalent liquid markup.

In any case, thanks for all the hard work with this project!

FormatException - Strainer.cs line 69

Hi there,
Thanks for your emails back to my other two bug reports. Just now is an insane busy time of year but I was forced to try out Liquid anyway when an urgent enhancement request made my current templating system infeasible. Around Jan/Feb next year I should have a lot more time to help out with your Liquid project including helping troubleshoot those two issues I reporting and any others since I plan to build a template editing feature and a few other more long term enhancements. In the meantime I'm buried and can only likely log the issues and hack things in my source code so I can answer the immediate needs.

Anyway as for this bug, here's the fix:

throw new SyntaxException("Filter '{0}' does not have a default value for '{1}' and no value was supplied", method, parameterInfos[i].Name);

Thanks!

  • Brian

Support for streaming datasets

I am working on a web application which writes out large sets of data from database directly to the response stream. Because of the streaming I don't have to hold all the data in memory.
Now I want to format this streaming data using liquid templates.

In my initial version I have created a liquid row template which is applied on each row of data before it's streamed out, it works fine but since I am applying template per row so I am not able to iterate over entire dataset and hence not able to create complex templates.

Liquid at the moment returns rendered output as string
public string Render(Hash localVariables = null, IEnumerable filters = null, Hash registers = null);

Ideally I want to inject my stream while calling the Template.Render and would like liquid to write the result directly into the stream .

public void Render(Stream stream, Hash localVariables = null, IEnumerable filters = null, Hash registers = null);

Are there any future plans to implement such streaming support in liquid?
Thanks

Includes tag fails with error. "Liquid error: Value cannot be null."

I have a directory: C:\temp\templates
With the files: test.liquid and _myInclude.liquid

test.liquid has the following:
{% include myInclude %}

and _myInclude.liquid has:
Hello World!

My code looks like this:
string path = @"C:\temp\templates\test.liquid";
string dir = Path.GetDirectoryName(path);
var fs = new LocalFileSystem(dir);
Template.FileSystem = fs;

string templateContents = File.ReadAllText(path);
Template template = Template.Parse(templateContents);

string result = template.Render();  

And from that I get the following error:
Liquid error: Value cannot be null. Parameter name: input
Occurs in LocalFileSystem.cs, FullPath(string), line 40

Issue with some types and conditions

Adding a byte or short into the variables causes some issues with conditionals:

var row = new Dictionary<string, object>();

short id = 1;   
row.Add("MyID", id);

var current = "MyID is {% if MyID == 1 %}1{%endif%}";
var parse = DotLiquid.Template.Parse(current);  
var parsedOutput =  parse.Render(new RenderParameters() { LocalVariables = Hash.FromDictionary(row) });

The output is "MyID is" when id is a short, byte or long. Works fine if it's an int. Any chance of making the system more type insensitive?

I would expect even if id was an int and the condition was {% if MyID == '1' %} it would attempt to convert and still work.

For now, I'm converting all byte/short/longs into int.

Support for multiple filters with the same name

I changed the way the filter methos are choosen to support filters with identical signature but different types, e.g.

class Filter {
   public static filter(double d) {}
   public static filter(decimal d) {}
}
public object Invoke(string method, List<object> args)
        {
            // Choose the method with least number of dynamic parameters
            MethodInfo methodInfo = _methods[method].Where(m =>
                {
                    ParameterInfo[] paramInfos = m.GetParameters();

                    // skip methods with too less parameters
                    if (paramInfos.Length < args.Count) return false;

                    // check if all extra parameters have a default value
                    for (int i = args.Count; i < paramInfos.Length; ++i)
                        if ((paramInfos[i].Attributes & ParameterAttributes.HasDefault) !=
                            ParameterAttributes.HasDefault)
                            return false;

                    // check if all parameters have the right type
                    if (args.Where((t, i) => !paramInfos[i].ParameterType.IsInstanceOfType(t)).Any())
                    {
                        return false;
                    }

                    return true;
                }).OrderBy(m => m.GetParameters()
                                 .Count(pi => pi.GetCustomAttributes(typeof (DynamicAttribute), true).Length > 0))
                                                    .FirstOrDefault();

            if (methodInfo == null)
                methodInfo = _methods[method].First();

            ParameterInfo[] parameterInfos = methodInfo.GetParameters();

            // If first parameter is Context, send in actual context.
            if (parameterInfos.Length > 0 && parameterInfos[0].ParameterType == typeof(Context))
                args.Insert(0, _context);

            // Add in any default parameters - .NET won't do this for us.
            if (parameterInfos.Length > args.Count)
                for (int i = args.Count; i < parameterInfos.Length; ++i)
                {
                    if ((parameterInfos[i].Attributes & ParameterAttributes.HasDefault) != ParameterAttributes.HasDefault)
                        throw new SyntaxException(Liquid.ResourceManager.GetString("StrainerFilterHasNoValueException"), method, parameterInfos[i].Name);
                    args.Add(parameterInfos[i].DefaultValue);
                }

            try
            {
                return methodInfo.Invoke(null, args.ToArray());
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
        }

Nested If support

I realize it might be a big request, but it would be nice to support nested If/Else/Endif statements.

Specify default filter.

It would be nice to be able to set a global filter. (e.g. Always HTML encode all values.)

I might expect this functionality to work like this:

Template.RegisterGlobalFilter(filter);

In this case, I'd probably make a special "unencode" filter so that if a user does NOT want HTML encoding, he/she could use this template: "Blah blah {{ name | unencode }} blah blah"

Allow any types, without ILiquidizable?

I am trying to pass something like the following object to a view:

var data = new {
   Model = GetMyData(),
   BaseUrl = "/something/";
};

public IEnumerable<Models.MyData> GetMyData();

The trouble is, due to the requirement to have ILiquidizable on all types, I get the error: Liquid syntax error: Object 'Models.MyData' is invalid because it is neither a built-in type nor implements ILiquidizable.

I understand this is by design, but it would be really nice to have the ability to override this restriction if I know that I am passing it a safe-to-use model. This is really annoying since I am specifically using DTOs already, and essentially the only way to get this to work is to implement ILiquidizable and return a new anonymous type that mirrors my actual model.

I tried using object DotLiquid.ILiquidizable.ToLiquid() { return this; } but that also does not work -- it just silently fails, as if the variables I'm referencing don't exist.

I can picture a couple of ways to do this:

// as a global setting
DotLiquid.Template.AllowAllTypes = true;

// as a wrapper:
Hash.FromSafeType(model);

// as an override
template.Render(DotLiquid.Hash.FromAnonymousObject(model, allowAllTypes:true));
// or
template.Render(DotLiquid.Hash.FromAnonymousObject(model), allowAllTypes:true);

The actual implementation is pretty easy once the method is chosen -- it's a matter of modifying Context.Liquidize().

I will submit a patch if needed, but want feedback and alternatives before I do.

(aside, the page linked in the docs of ILiquidizable -- http://wiki.github.com/tobi/liquid/using-liquid-without-rails -- is gone. It appears to be https://github.com/Shopify/liquid/wiki/Using-Liquid-without-Rails/cadb5d13cb171d36b4aa9239af1b8b70bc699ad1 but I can only find this referenced by search, the current version of that page is also missing?)

Implement ERB-like trimming for leading whitespace

DotLiquid already supports ERB-like trimming for trailing whitespace, using the -%} or -}} syntax.

ERB also supports trimming for leading whitespace, using the <%- syntax. We should implement the same type of trimming for DotLiquid.

Doesn't appear to be a way to get the current date/time

According to docs, this should be the current date/time:

{{ 'now' | date: "MM/dd/yyyy" }}

Looking at the code, there is no way to get the current date time.

Minor to fix:

public static string Date(object input, string format)
    {
        if (input == null) return null;

        if (format.IsNullOrWhiteSpace()) return input.ToString();

        DateTime date = DateTime.Now;

        if (string.Compare(input.ToString(), "now", StringComparison.InvariantCultureIgnoreCase) == 0 || DateTime.TryParse(input.ToString(), out date))
        {
            return Liquid.UseRubyDateFormat ? date.ToStrFTime(format) : date.ToString(format);
        }

    return input.ToString();
    }

Assign error on european decimals format

Hello, I have some errors tring to sum some decimal values.

{%assign test=2,5%} returns 2
{%assign test=2.5%} returns 25

The first is a regular expression issue
The second is a Convert issue.

Thank you for you great lib!

Parsing speed increases by using static compiled regex

Just convert the existing regex into static and compiled. E.g. (in Context.cs)

    private static readonly Regex _sinqleQuoteRegex = new Regex(R.Q(@"^'(.*)'$"), RegexOptions.Compiled);
    private static readonly Regex _doubleQuoteRegex = new Regex(R.Q(@"^""(.*)""$"), RegexOptions.Compiled);
    private static readonly Regex _integerRegex = new Regex(R.Q(@"^([+-]?\d+)$"), RegexOptions.Compiled);
    private static readonly Regex _rangesRegex = new Regex(R.Q(@"^\((\S+)\.\.(\S+)\)$"), RegexOptions.Compiled);
    private static readonly Regex _floatsRegex = new Regex(R.Q(@"^([+-]?\d[\d\.|\,]+)$"), RegexOptions.Compiled);

Thanks.

Unexpected behaviour of the LiquidType attribute

If I inherit a class from Drop all members of that class are available in the template. Thats fine. :)

If I don't inherit from Drop but mark the class with the [LiquidType] attribute I would expect the same behaviour (all members should be available in the template).

But I have to add all member names to the attribute like [LiquidType("Member1", "Member2", ...)] to make them available. I just found that by having a look into the source code. That wasn't clear by reading the documentary.

So it would be great to either
a) update the documentary or
b) change the behavior (if possible).

What do you think?

[RFC] localizing exceptions

Hi,
as you all already know, DotLiquid is an end-user faced template engine.
I think that in most cases (if not all) every syntax-related exception should be thrown to the end user, and as such we should provide a way to localize them, without having developers do exceptions messages parsing magic.
I have a working initial implementation in my private tree which uses the standard resx files and satellite assemblies, but before committing it I would like to know your opinion.

Ciao,
Alessandro.

ILiquidizable and domain-desing

Hello,

Thanks for dotliquid. It is pretty useful but in our project we have a lot of components which used single assembly where domain model is defined. I cannot inherit the model entities from the "ILiquidizable" interface. I know this is not a ruby style but I think it would be good if there will be any possible to define logic of the "ToLiquid" method in some another place. What do you think about it?

Nested Template Inheritance Not Correctly Placing Blocks

There appears to be a bug with nested template inheritance not working when an intermediate template defines a block inside of an inherited block. For example, consider the following three templates:

Outer:
A {% block outer %}{% endblock %} Z

Middle:
{% extends "Outer" %}
{% block outer %} B {% block middle %}{% endblock %} Y {% endblock %}

Inner:
{% extends "Middle" %}
{% block middle %} C {% endblock %}

The expected output should be "A B C Y Z" but instead this outputs "A B Y Z C".

render nil tags

Hi all,
I'm currently switching the template engine of one of my biggest projects and I need to render nil tags so my users can manually replace values in it.
In a fork of Ruby's Liquid there's already an implementation of it (sakrafd/liquid@8a4048d), which I'm going port to DotLiquid.

Any thoughts?

Importance of Drop object property case is not clear

First off, thanks for porting Liquid. I have used it with Jekyll before and am looking forward to using it in .NET.

The Nuget install experience was great, but I subsequently wasted about 2 hours working out that CamelCased property names (like ProductId) in Drop objects convert to variable names with spaces in them i.e. (product_id). This caused my a lot of frustration and hair pulling :)

This is feedback really, but I could not find a DotLiquid group (does one exist)? I was going to make a Pull request with a change to the Drop documentation wiki page, but thought I would raise this here first to confirm this behaviour. While I'm sure it's by design, I can imagine the lack of warning or documentation, harming adoption (as a lot of people will probably have a CamelCased property in their first drop object).

Cheers,

Ben

Issue in Extends.cs can cause memory issues.

b.AddRange should be moved - see below

if (block != null)
{
    Block found = b.Find(bl => bl.BlockName == block.BlockName);

    if (found != null)
        found = block;
    else
        b.Add(block);
}

b.AddRange(FindBlocks(n, b)); // this line should be moved up into the if statement

decimal type not supported

Hi there,
Fantastic templating system so far... well done!

If I try to set a variable of type decimal, it throws an exception that this isn't supported. I think it should be "safe" since it's such a basic .NET type...

I tried on Context.cs around line 383 (private static object Liquidize(object obj)) to add an if statement checking decimal, but then that throws an error later in the code, so I wasn't sure how to fix it easily.

Thanks again for a great toolkit. I tried stringtemplate and it sucks (way too basic) and I didn't find anything else out there I quite liked until I gave yours a try.

Regards,

  • Brian

Sign DotLiquid assembly so it can be used in the GAC

We've had a request to sign the DotLiquid assembly so that it can be used in the GAC. I think this makes sense.

Jon Skeet has some thoughts on this: for his project Protocol Buffers, he simply added the .snk file to the repository. For his later project Noda Time, he plans to add a "public" .snk to the repository, but create official builds with a "private" .snk..

My preference is to keep it simple and go with the first option - just add the .snk file to the repository. This does mean that anybody can create "official" builds, but I don't see that as a big problem. If anybody is concerned about that, they can just go to the official downloads page and get the binaries from there.

Thoughts?

Working with Dictionary object when key is not KNOWN

I have a basic .NET Dictionary (Dictionary<string,string>). In my ToLiquid method I do indeed serialize/expose the Dictionary object. My question is how can I ITERATE over the keys in a liquid template just as you would do in regular .NET? It seems as though you MUST know the actual key in order to access the value in the liquid template.

I understand that you could access the value in the liquid template like such

item.dictionary["myKey"]

However I don't know the actual key, so I would prefer to use the "for" construct in DotLiquid to iterate over the keys in order to get the various values. Since the "for" construct works on collections and Dictionary is a collection I thought this could be done somehow but all permutations that I have tried have failed.

Any help would greatly be appreciated.

NamingConvention and IIndexable or IDictionary

Hi Tim,
it seems we have a major bug... if we pass in an IIndexable or IDictionary, DotLiquid does not take into account NamingConvention and keys resolution fail.
I've been looking on a way to resolve but found anything, do you have any idea?

Some issues

e.g.

{% for p in ViewBag.BestsellerInCategory %}
{% assign fidx = forloop.index | Plus:1 %} -> this isn't working
{{fidx}}
{% endfor %}

I think it should write 2, 3, 4, 5. The result is 1, 2, 3, 4

BestsellerInCategory is an ENumerable variable.

{{ViewBag.BestsellerInCategory | Size}}

it gives me 12 and there are 12 items in it. Right.

{% assign tbic = ViewBag.BestsellerInCategory | Size %}
{{tbic}} -> this is not working

this code causes to be written ....Drops .... Drops. It writes class names

another code:

{% assign a = 1 %} -> this works
{{a}}
{% assign b = a %} -> this works
{{b}}
{% assign c = a | Plus:1 %} -> not working
{{c}}

I expect it 1, 1, 2
but the result is 1, 1, 1

Date filter implementation not compatible with Ruby Liquid

The format string syntax used by the "date" filter is not the same as the format string syntax used in the Ruby Liquid implementation. This is because each implementation is calling its underlying runtime date formatting function and these are not compatible. Is this level of compatibility a goal for DotLiquid?

modifying Assign regex to allow filters

Hi Tim,
I've implemented the split filter and would like to also port some few changes from Ruby's Liquid.
It seems we have some difference in the assign syntax and so far I've not been able to modify it to allow filters.
Any idea?

private static readonly Regex Syntax = R.B(R.Q(@"({0}+)\s_=\s_({1}+)"), Liquid.VariableSignature, Liquid.QuotedAssignFragment);

Allow filters to access context

In my current project, I need to write a filter that has access to the current Context (to extract something from the Registers). I'm thinking of making a change to Strainer such that if the first parameter to a method is of type Context, it knows what to do. So my filter might look like this:

public static string MyFilter(Context context, string input)
{
  // Can access context here.
  return result;
}

Liquid in Ruby can do this already, because the @context variable is available to all filters.

Thoughts?

Object with camel-cased Properties

When an object contains camel-cased properties for example:

public User : Drop
{
    public int ID { get; set; }
    public string UserName { get; set; }
}

Then won't work with DotLiquid, however if they're either lower case, or capitalized, for example

public User : Drop
{
    public int Id { get; set; }
    public string Username { get; set; }
}

They will work and render output correctly. Is there anyway to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.