Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushing new context to stack #2

Closed
bckfnn opened this issue Jun 19, 2012 · 3 comments
Closed

pushing new context to stack #2

bckfnn opened this issue Jun 19, 2012 · 3 comments
Assignees

Comments

@bckfnn
Copy link

bckfnn commented Jun 19, 2012

Thanks for the nice implementation.

Are there a way from within a helper to push some new values on the existing context stack and then apply an unrelated template with the whole stack?

As a silly example, here is an include helper where I would like to read another template and render it, but with some additional values in the context.

    handlebars.registerHelper("include", new Helper<String>() {
        public CharSequence apply(String path, Options options) throws IOException {
            Map<String, Object> ctxt = new HashMap<>();
            ctxt.put("var", "value");

            Template included = handlebars.compile(new URI(path));

            return options.apply(included, ctxt); // this method is private and cannot be used like this.
        }
    });

All the available methods to render a template appears to all create a new stack without access to existing values.

@jknack
Copy link
Owner

jknack commented Jun 19, 2012

Thanks for your feedback!

Yesterday, I was thinking the same thing.

Wait for news.

edgar

@ghost ghost assigned jknack Jun 19, 2012
jknack added a commit that referenced this issue Jun 20, 2012
* pushing new context to stack #2
* Access to values in context stack #3
* Safe partials in the current execution. Template Inheritance
* Support template inheritance
* fn, inverse, params and hash are public and final fields of Options
* Rename 'scope' reference to 'context'
* Bug fix for null outputs
@jknack
Copy link
Owner

jknack commented Jun 20, 2012

Hi,

Options#apply is a public method now. Also, in the last commit there are two new helpers: "block" and "partial". The two new helpers were created for Template Inheritance Support.

See here for more information

Thanks!

@jknack jknack closed this as completed Jun 20, 2012
@bckfnn
Copy link
Author

bckfnn commented Jun 20, 2012

A huge thank you for the fixes. Also for the block/partial helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants