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

Partial Block and Passing Scope #53

Open
damncabbage opened this issue May 25, 2016 · 3 comments
Open

Partial Block and Passing Scope #53

damncabbage opened this issue May 25, 2016 · 3 comments

Comments

@damncabbage
Copy link
Contributor

damncabbage commented May 25, 2016

test.json:

{ "donut": { "title": "Hello!" } }

test.hbs:

{{#*inline "donut"}}
<h1>{{> @partial-block }}</h1>
{{/inline}}

{{#>donut}}
  {{~ donut.title ~}}
{{/donut}}

{{#>donut donut}}
  {{~ title ~}}
{{/donut}}
$ cat test.hbs | dist/build/BMX/bmx -c test.json
Rendering error at line 10, col 7:
  Invoked value 'title' is not defined

This works with Handlebars.js (locally and tryhandlebarsjs.com both produce: <h1>Hello!</h1>\n\n<h1>Hello!</h1>), but doesn't work with BMX. 😰

Handlebars.js' behaviour, as I was explaining earlier to @russmaxdesign and @charleso, does not match my mental model of how the hell this is meant to work. Whether we choose to support this + "fix" the BMX implementation, or disallow this behaviour entirely, is up for discussion I think.

@damncabbage
Copy link
Contributor Author

ps: sorry

@thumphries
Copy link
Contributor

The implementation of partial blocks is a total hack, I just evaluate it in the outer (calling) scope and inline the result. i.e. {{> @partial-block donut }} is intentionally broken.

I don't think this case makes sense, though? Aren't partial blocks always meant to be evaluated in the outer scope, and the argument is just for the partial itself?

@damncabbage
Copy link
Contributor Author

Posting this upstream: handlebars-lang/handlebars.js#1226

In the mean time, we'll avoid use of this scope-object-passing thing.

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

No branches or pull requests

2 participants