Sunday, 15 September 2013

templates - Using hapi and handlebars, with the default layout support from hapi, can alternative layout be selected from with a page? -


and the Happy AP indicates that Happy has made the layout in support of the bars while using bars, though it seems By default, to allow defining a layout in the configuration as the layout of the 'layout.html' layout,

to use Handlebar layout support to do this within a page like this How Handler-Layout Is Used:

  {{Expand "Layout 2"}} {{/ Detail}}  

When I'm able to use handlaw-layout, I use only that much stuff I would like to do that which provides hapi.

Is it possible that the default layout is higher than that and select that layout in the page template? Maybe it happens:

  {{!!  

/ P>

option - Alternate object to override the view manager configuration of the server for this response isCached , partial page , or helpersPath , which are only loaded initially.

Here is an example:

index.js:

  var handballbar = ('handlers'); Var Happi = Required ('Happy'); Var path = required ('path'); Var Server = New HAPI Server () server.connection ({host: '127.0.0.1', port: 8000}); Path.join (__dirname, 'views / layouts'), layout: 'default' (server: view) ({engine: {html: handlebars.create ()}, path: path.joined (__derenname, 'view' ), Layout path:}); Server.route ({method: 'GET', path: '/ default', handler: function (request, answer) {reply.view ('item', {title: 'item title', body: 'item body'} );}}); Server.route ({method: 'GET', path: '/ custom', handler: function (request, answer) {reply.view ('item', {title: 'item title', body: 'item body'} , {Layout: 'custom'});}}); Server.start ();  

View / Layout / custom.html:

  & lt; Html & gt; & Lt; Body & gt; & Lt; H1 & gt; Custom layout & lt; / H1> {{{Content}}} & lt; / Body & gt; & Lt; / Html & gt;  

view / layout / default.html:

  & lt; Html & gt; & Lt; Body & gt; & Lt; H1 & gt; Default layout & lt; / H1> {{{Content}}} & lt; / Body & gt; & Lt; / Html & gt;  

view / item.html:

  {{body}}  

when you visit It will use default.html . However custom.html .


No comments:

Post a Comment