Skip to content

IncludeHelper #217

@tomvanrossom

Description

@tomvanrossom

I'm trying to use the includeHelper, but I'm having some troubles.

In my templates I've got something like this:

{{include "templateName" includeContext=modelAttribute}}

and in the template "templateName" I'm trying:

{{includeContext}}
{{#includeContext.property1}}
   {{property2}}
{{/includeContext.property1}}

The "{{includeContext}}" prints out something, the "{{property2}}" not (although there is data in it)!

When I debug the code I see that the IncludeHelper copies the hashes to the context.data

public CharSequence apply(final String partial, final Options options) throws IOException {
    // merge all the hashes into the context
    options.context.data(options.hash);
...

But when the actual data is retrieved in the class "Block"

protected void merge(final Context context, final Writer writer) throws IOException {
    ...
    if (helper == null) {
      childContext = transform(context.get(name));
      ...

The following method of Context is eventually called:

private Object get(final String[] path) {
    Object current = model;

This method used the 'model' instead of the 'data'. I find this strange, because the IncludeHelper copied the hashes to the data, and not the model!??!

What am I doing wrong? Or is this an issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions