Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Meteor: How to expose a variable as the view context for a template? #175

Closed
halgorithm opened this Issue · 1 comment

2 participants

@halgorithm

According to https://github.com/bminer/node-blade/wiki/Using-Blade-with-Meteor,

<template name="foo">
 {{#each bars}}
   {{> bar}}
 {{/each}}
</template>

might look like this in Blade:

foreach bars as bar
  include "bar" exposing bar

However, the difference between these two is that Handlebar's way makes bar become this within the "bar" template. This allows the "bar" template to use {{name}} and {{whatever}} instead of {{bar.name}} and {{bar.whatever}}. How could you do that with blade?

Also, is there any way to expose a local under a different name, like include "bar" exposing { coolBar: bar } or include "bar" exposing bar as "coolBar"? Not sure what the syntax would be, or if that would even be the right way to accomplish such a thing...

@bminer
Owner

However, the difference between these two is that Handlebar's way makes bar become this within the "bar" template. This allows the "bar" template to use {{name}} and {{whatever}} instead of {{bar.name}} and {{bar.whatever}}. How could you do that with blade?

Answer: you can't do that with Blade. It is a fundamental difference between Blade and Handlebars.

Also, is there any way to expose a local under a different name, like include "bar" exposing { coolBar: bar } or include "bar" exposing bar as "coolBar"? Not sure what the syntax would be, or if that would even be the right way to accomplish such a thing...

You also cannot really rename the locals. The only way would be something like this:

- var foo = bar
include "abc" exposing foo

... instead of just exposing bar, you expose foo, effectively renaming the local.

Closing this issue for now.

@bminer bminer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.