Giter VIP home page Giter VIP logo

fumanchu's People

Contributors

antaris avatar freshegg-matt avatar

Stargazers

 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

fumanchu's Issues

HTML Escaping not working

Added unit tests for expression tags has highlighted that although the parser supports the {{{...}}} tag syntax, the SyntaxTreeRenderer<T>.Write method isn't actual considering the RenderContext.EscapeEncoding setting, therefore content is always being encoded.

NRF executing basic IS template

using FuManchu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string template = "{{#is Value != 1}}True!{{/is}}";
            string content = Handlebars.CompileAndRun("test", template, new { Value = 2 });

            Console.WriteLine(content);
            Console.ReadKey();
        }
    }
}

Question: How to write a helper which support @first, @last, @index

Hi, I want to define a helper which can perform a loop, and as part of this, I'd like to pass in the @FIRST, @last and @Index variables. I notice this is possible in the EnumberableRenderer, but I'm not sure how I go about implementing this in an helper declared inline using the RegisterHelper interface.

Do you have an example of how to implement this?

Problem running template inside template

I've created a template like this:

{{#range 1 10}}
  {{#if @index}},{{/if}}
  {
      // Some json content
  }
{{/range}}

I'm using a custom helper for the "range" tag, which all works fine, however there seems to be a problem with the if statement inside it. Running handlebars, rather than getting a list of object tags separated by a comma, I get a bunch of commas all grouped together, then the list of objects next to them (not comma seperated).

,,,,,,,,,{}{}{}{}{}{}{}{}{}{}

I'm trying to debug in at the moment, but it looks to be down to the fact that at some point, the span renderer for the comma renders against the writer that is in the scope, which is the current outer blocks scope, rather than the writer generated for the range helper, thus all the commas get written to the main writer, then on completion of the helper, all the other objects are written to the writer directly afterwards.

I'm currently getting really confused with the visitor rabbit whole to be able to narrow it down to a specific location, but any help would be greatly appreciated.

Add support for {{#is...}} helper

Dan Harper implemented some useful Handlebars extensions in his repo at https://github.com/danharper/Handlebars-Helpers.

The {{#is...}} helper builds on the purpose of {{#if...}} with different semantics, adding support for different types of comparison operators, and custom operators.

The standard operators include:

  • == (equality)
  • != (negated equality)
  • not (alias for !=)
  • === (strict equality)
  • !== (strict negated equality)
  • > (less than)
  • >= (less than or equal to)
  • < (less than)
  • <= (less than or equal to)
  • in (exists within a set)

These could add serious flexibility to FuManchu, but need to be careful with strict vs. non-strict, in terms of type conversions.

Add support for inverted sections using '^'

Mustache supports the following:

{{^person}}...{{/person}}

Which is the equivalent of:

{{#unless person}} {{/unless}}

I've also seen instances of:

{{#person}}
    {{name}}
{{^}}
    No person :-(
{{/person}}

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.