How to pass parameters to default template?


#1

like below:

{{!< default test="dddd"}}

how to pass? I tried above, but seems no work


#2

You can’t pass parameters to the default template because it’s not actually handlebars. The library that Ghost uses (express-hbs) checks if you declared a layout separately.

If explain your usecase, someone might be able to give you a different solution


#3

different page has different js, css file, if just put these into default template directly , you need write a lot of if else, i think it was dirty, if I can pass from page, it will be better


#4

The contentFor / block helper is your best bet


#5

is ghost use ‘express-hbs’ default ? so I can use
{{#contentFor “pageScripts”}}
CONTENT HERE
{{/contentFor}}
without install it any more ?


#6

I’m not sure I understand your question.

The contentFor helper is added by express-hbs so you don’t need to do anything special to your installation to make it work.

You can see an example of how this helper is used in Casper:

contentFor:

block:


#7

thank you very much, help a lot!