Giter Club home page Giter Club logo

mustache.cfc's People

Contributors

awayken avatar daamsie avatar david-mulder avatar davidgortega avatar dswitzer avatar markmandel avatar pmcelhaney avatar rip747 avatar seancoyne 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

Watchers

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

mustache.cfc's Issues

Public methods in Mustache are available as lambda

One of the issues with the way that a component can extend the Mustache.cfc and use it's public members as context, is all public methods end up being available as lambdas.

This means the Mustache methods of init, render, getPartials and setPartials all are available. If you end up with a template that has the text "{{init}}" in the code, then CF ends up throwing an error because the "init" function tags a struct as an optional argument (not a string.)

The bigger issue is that these public methods shouldn't even be allowed to be part of the context.

One way to solve that would be to filter out these public methods from being included as context. This would fix the problem, but it does limit templates from ever using these keys as valid context (which could be problematic for some corner use cases.)

We probably also want a way to register other public methods that should be excluded from context--in cases where you've extended Mustache w/additional functionality.

Support accessing parent scope within an iterator

Is this a shortcoming that anyone else has discovered with the CF implementation?

http://jsfiddle.net/ZG4zd/20/ (found via StackOverflow)

This lib does not reach up the chain into the parent scope and beyond; it's my belief that feature is required to maintain spec compliance with Mustache.

Has anyone else run into this that has a solution? I'd love to explore some ideas around it, even if it not deemed valid for this repo.

Pass in context to lambda functions?

Right now the lambda function only retrieve the template code as an argument.

However, I started thinking that it would make some sense to pass in a reference to the "context" item as an argument as well, so that you could potentially cache the results of the function call by replacing the context on-the-fly.

This obviously doesn't always make sense, but I have some situations where I have some variables I want to do as a lambda because the lookup expense is costly and they're not always used. By passing in a reference to the context item, I could change the context to point to the rendered string (instead of the function.)

Does anyone else think it's worth adding?

Here's a little proof of concept showing the basic idea would work:

// function to show off lambda
function cacheTest(context, item){
    var results = createUUID();
    // here we cache the results in the original context object
    context[item] = results;
    return results;
}

// a sample context object
context = {test=cacheTest};

for( i=1; i <= 10; i=i+1 ){
    // this logic is handled by the get() method
    if( isCustomFunction(context.test) ){
        x = context.test(context, "test");
    } else {
        x = context.test;
    }
    // show the results
    writeOutput("<div>#i# = #x#</div>");
}

OpenBlueDragon is not accepting Mustache.cfc

Hi, I have used Mustache.cfc since Coldfusion, then I moved to Railo without problems but in openBD It comes with this exception.

Type Application
Detail Problem occurred while parsing: render(arguments.inner, ctx)
Extended Info The function render requires at most 1 argument(s).

I see in the code that the render function has the two arguments so the only idea that I could have is some parsing mistake. Any ideas?

No mention of mxunit in README

There is no mention of the need to install mxunit to have this framework actually work - unless it isn't required, and is only required to make the "tests" folder work - in which case it should still be mentioned somewhere.

Support for changing or escaping delimiters

Wondering how to handle the (unlikely but possible) case where {{ or }} is needed in a template.

As I understand it, Mustache supports this syntax to change delimiters before compiling:

Mustache.tags = ["[[", "]]"];

It also supports changing delimiters on the fly like this:

{{=<% %>=}}

Far as I can see, neither of those variants are supported by MustacheCFC. Am I right about that? If so, could they be, or are there other alternatives?

Compile Mustache -> ColdFusion

Starting up an issue, so we can discuss implementation, as I've been thinking about this a lot.

The issue with converting mustache is that what sections and variables do at runtime differ depending on what the variable is at runtime.

So the way I see this working is that each {{#section}} would need to be converted to a function (probably one that allowed for output to make life super easy). That way you could do type checking at run time to determine what the type of the object is, and then react accordingly.

You would need to store the inner parts of the original mustache template, so it can be passed to lamda's as well.

Anyone see any major issues with that sort of implementation?

Direct addressing of specific array elements

This works fine, iterating over the elements in an array:

data = {arr=[10,20,30]};
template = "{{##arr}}{{.}}{{/arr}}";
writeOutput(mustache.render(template, data));

How can you show just element 2, say? Not with any of these seemingly intuitive constructs:

template = "{{arr.2}}";
template = "{{arr[2]}}";

My actual use case is more like this:

data = {arr=[{a=10, b=11}, {a=20, b=21}]};
template = "{{arr.2.b}}"; // or whatever would work to output '21'

The similar case of addressing a specific struct item does work, for instance:

data = {s={a=10, b=20, c=30}};
template = "({{s.b}})"; // -> '20'

Is the array element index version of this possible today with some syntax I missed?
If not, is it a reasonable enhancement?

Thanks.

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.