GithubHelp home page GithubHelp logo

mikebridge / liquid.net Goto Github PK

View Code? Open in Web Editor NEW
62.0 8.0 15.0 1.3 MB

.Net Port of the Liquid template language

License: MIT License

C# 96.47% Ruby 1.24% ANTLR 1.80% Liquid 0.32% C 0.17%
liquid c-sharp templates

liquid.net's Introduction

Liquid.NET Liquid.Net

Build status Gitter codecov.io NuGet

Liquid.NET is a C# port of the Liquid templating language.

It can be downloaded via NuGet. There's more information on the Liquid.NET Wiki.

Start from zero with the Quick Start wiki page.

Liquid.NET targets netstandard2.0 and net452.

Liquid.NET is an independent project and I am not affiliated in any way with Shopify.

liquid.net's People

Contributors

mikebridge avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liquid.net's Issues

Capture does not allow captured template fragment to modify global state

When array is four items, this should return "odd even odd even". However, it returns "odd odd odd odd", because the capture tag does not allow the cycle tag to write to global state.

{% for item in array %}{% capture thecycle %}{% cycle 'odd', 'even' %}{% endcapture %}{{ thecycle }} {% endfor %}

This also affects the "macro" tag.

Ignore static properties in LiquidValueConverter

The current implementation of the LiquidValueConverter includes static properties from classes, which is probably not intended (at least it was not expected behavior when we tried using it).

Example class:

public class ViewModel
{
    public string Title { get; set; }
    public static string OtherData { get; set; }
}

Code sample:

ViewModel.OtherData = "aaa";
var liquid = new ViewModel() { Title = "bbb" }.ToLiquid();

Expected result:

After executing the code sample, the liquid object should only include the Title property.

Observed result:

After executing the code sample, the liquid object includes both the Title property and the OtherData property.

Liquid c# context initialize variable with T type

ITemplateContext ctx = new TemplateContext(); List<Orders> ProductList = new List<Orders> { new Orders {OrderId = 1,ProductName="Some name",Quantity =30}, new Orders {OrderId = 1,ProductName="Some name1",Quantity =30}, new Orders {OrderId = 1,ProductName="Some name2",Quantity =30} }; ctx.DefineLocalVariable("context", new LiquidCollection(ProductList));

Define Liquid Collection with List throws error. Is it possible to define T type generic collection as ITemplateContext-> LocalVariable

Add simple POCO-to-LiquidHash translator

It would be nice to have a simple POCO-to-LiquidHash translator that

  • works recursively
  • takes int, decimals, String, IDictionary, IList/IEnumerable, etc. properties and other POCOs and maps them to the Liquid* classes.
  • has attributes to exclude properties and rename them.

Json dump of a liquid hash is invalid.

Currently whenever I dump a liquid hash, it serializes empty enumerables into nothing. Also, enumerables aren't wrapped in brackets, and each item in the list isn't being separated from the next with a comma.

Example:
{ facets: , results: { name: 'Test' } { name: 'Test2' } }

Expected value:
{ facets: [], results: [{ name: 'Test' }, { name: 'Test2' }] }

Move to xunit

Having enough problems with dotnet core and nunit to warrant switching horses.

Add ability to assign value to hash

{% assign myhash.newvalue = 1 %} should add/update a value in a hash. Similarly,{% assign myhash.mysubhash.newvalue = 1 %} should work as expected.

Assigning to a non-existent value or a non-hash should generate an error.

This should work for capture too.

(Note: This is not a feature of Shopify Liquid)

Remove ability to wrap null strings in LiquidString

Now Strings must be created via the factory method LiquidString.Create(String str). This enforces the LiquidString.StringValue to be non-null. The factory method will return null if the string value is null.

This also allows a programmer to take advantage of type-inferencing on methods that accept an Option, because passing null will automatically be promoted to Option.

Upgrade Appveyor

Get Appveyor, OpenCover + XUnit + netcoreapp1.1 + CodeCov working

Rename the types

After reworking the DictionaryValue and ArrayValue types, which subclass IExpressionConstant, they should really be named to correspond more closely with liquid types, e.g. LiquidHash, LiquidCollection, etc.

Liquid template convert to json from object

` List ProductList = new List
{
new Orders {OrderId = 1,ProductName="Some name",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name1",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name2",Quantity =30}
};

        ctx.DefineLocalVariable("content", ProductList.ToLiquid());

        // Note that you will still get a best-guess LiquidTemplate, even if you encounter errors.
        var liquidTemplate = LiquidTemplate.Create(@"[
            {% for sales in content %}
                        {
                            ""SalesId"": ""{{sales.OrderId}}"",
               ""ProductName"": ""{{sales.ProductName}}"",
               ""Quantity"": ""{{sales.Quantity}}""
                        },
            {% endfor %}
            ]").OnParsingError(errors.Add)
            .LiquidTemplate;`

Parsing Liquid object to json . No conversion done.

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.