by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 18 02:10
    shannonmoeller labeled #43
  • Jul 18 02:10
    shannonmoeller commented #43
  • Jul 16 08:16
    SalttySugar commented #43
  • Jul 16 08:16
    SalttySugar commented #43
  • Jul 07 16:06
    amimas commented #49
  • Jul 04 13:54
    shannonmoeller commented #49
  • Jul 04 13:48
    amimas opened #49
  • Apr 13 19:00
    shannonmoeller closed #48
  • Apr 13 19:00
    shannonmoeller commented #48
  • Apr 13 16:33
    yogevlahyani commented #48
  • Apr 13 15:39
    shannonmoeller commented #48
  • Apr 13 13:54
    yogevlahyani edited #48
  • Apr 13 13:54
    yogevlahyani opened #48
  • Jan 22 20:59
    paceaux edited #47
  • Jan 22 20:59
    paceaux commented #47
  • Jan 22 20:08
    paceaux commented #47
  • Jan 22 20:04
    paceaux opened #47
  • Oct 31 2019 08:57
    martyan closed #46
  • Aug 26 2019 10:56
    martyan edited #46
  • Aug 26 2019 10:56
    martyan opened #46
glraj
@glraj

I understand we have namespace options in handlebars like this

options: {
namespace: 'MyApp.Templates'
},
but i am not sure what is significant benefit we get by this option. We can still live with common template path and not create separate object from JST but if there will be significant difference or advantage, I am curious to know.

Shannon Moeller
@shannonmoeller
@glraj Your question appears to be about a grunt-contrib-handlebars option rather than my layouts plugin.
The only advantage is that you can make your template namespace more consistent with the rest of your application, rather than being forced to use JST. If JST suits your needs, you're good to go.
Rob
@borriej
hi any activity here?
Shannon Moeller
@shannonmoeller
@borriej, a bit. What's up?
Dipen
@dtrce
I have custom helper which takes {{ custom "someString" input="test" }}
someString is stored in this.name
Shannon Moeller
@shannonmoeller
@dtrce Sorry for the late reply. I was out of town. If someString is in this.name, you can use the value this way: {{custom name input=“test”}}. By not putting quotes around name, it will use the value of the variable name.
CrystKen
@CrystKen
hi Shannon, can u plz provide an example for {{#embed}}. as i cant find it working in my project. I am using Assemble.io and grunt.
Shannon Moeller
@shannonmoeller
@CrystKen Sorry for the delayed reply. You use embed any time you would normally use the partial syntax ({{> foo/bar}}). What partials are available to you depends on your Assemble.io setup.
There is an example of using {{#embed}} in the project README. https://github.com/shannonmoeller/handlebars-layouts#embed-partial-keyvalue-
CrystKen
@CrystKen
thanks Shannon, just one more doubt, I understand the #extend functionality and its working pretty good on my projects, but can you plz give any example of using "[key=value ...]" in this context. like its given in {{#extend [partial] [key=value ...]}}.
Shannon Moeller
@shannonmoeller
Sure.
Let's say you have an image partial.
<img src="{{url}}" alt="{{title}}" />
If you pull it in as a partial, you can pass the "url" and "title" along as arbitrary attributes.
{{> partials/image url=foo.bar.imageUrl title=foo.bar.imageTitle }}
You can do the same thing with {{#extend}} and {{#embed}}.
Lets say you have a slightly more complex image partial.
<figure>
    <img src="{{url}}" alt="{{title}}" />
    <figcaption>{{{block "caption"}}}</figcaption>
</figure>
You could do this...
Shannon Moeller
@shannonmoeller
{{#embed url=foo.bar.imageUrl alt="A great image."}}
    {{#content "caption"}}Something interesting happened.{{/content}}
{{/embed}}
CrystKen
@CrystKen
thanks a ton shannon, its really helpfull. thanks a lot.
Chris Rutherford
@cjrutherford
hey guys, I want to insert a date into my template, I'm using jsreport, and I don't want to have it on an object...... How Can I do that? I was setting a variable on the JS side of the template as var today = new Date(Date.now()); and then adding to my template like {{today}} is there a better way?