> return Handlebars.precompile(item.data)
item.data = template.html; // inside with {{someAttribute}}
var obj = { someAttribute:someValue },
precompile = Handlebars.compile(item.data);
return precompile(obj);
works
--Harald
On Thu, Nov 19, 2015 at 5:17 AM, ermouth wrote:
> > I think it should be possible to use ermouth's ddoc.me to obtain the
> same
> > result much more easily. Maybe he can speak for us..
>
> Since Ddoc Lab can post-process each item with individual code for an item,
> you can precompile your data in any suitable way before publishing. You can
> even keep you templates in external docs – Ddoc Lab is able to fetch
> externals before processing.
>
> To have handlebars inside Ddoc Lab document, you should:
>
>- create any code snippet, it can be dummy
>- mark it as having postprocessor
>- put HB code into postprocessor and make pre-checker wrapper, which
>will prevent HB init, if it was already initialized
>
> Now each postprocessor have access to window.Handlebar. This approach is
> usefull for other libs also.
>
> So to have your template precompiled, just write a template and
> postprocessor for it (think `return Handlebars.precompile(item.data)` –
> will be enough).
>
> ermouth
>
> 2015-11-19 4:52 GMT+03:00 Giovanni Lenzi :
>
> > Hi Robin and Nick,
> > You definitely CAN output full html, non js, SEO optimized web pages. We
> > use that for our store index and apps pages (on
> > https://www.smileupps.com/store).
> >
> > We needed to:
> > 1. create html templates of your pages with a templating library(we used
> > handlebars.js),
> > 2. precompile these templates before 'couchapp push' as server side
> > javascript file in ddoc, such as lib/templates.js
> > 3. create a view with name(path) of your page as key, emitting documents
> > containing information of a same page under the same key. These elements
> > may be html for header, links for navigation bar, markdown or raw html
> for
> > your page content, a list of apps, or anything else
> > 4. create a list which uses:
> > - getrow() to fetch above elements in memory,
> > - var tpls=require(lib/templates),
> > - obtain html by merging templates and documents:
> > htmlforheader=tpls.header(headerdocument),
> > htmlfornavbar=tpls.navbar(linksdocuments)
> > - return/output html from the list function
> >
> > Probably the most difficult part is to precompile correctly those
> > templates, in a way you can use them server side withouth issues. We
> used a
> > node.js handlebar precompiler automatically run before 'couchapp push',
> but
> > I think it should be possible to use ermouth's ddoc.me to obtain the
> same
> > result much more easily. Maybe he can speak for us..
> >
> > Hope this helps,
> > --Giovanni
> > Il giorno 19/nov/2015 00:13, "Robin Millette" ha
> > scritto:
> >
> > > Hi,
> > >
> > > First time writing to this list, or any couchdb list for that matter.
> > > Hope to see a brillant couchapp (the concept) revival in 2016!
> > >
> > > On Wed, Nov 18, 2015 at 5:53 PM, Nick
> > wrote:
> > >
> > > > Thanks - which indeed implies I am right and there is no solution
> that
> > > works
> > > > without JS on the client...
> > >
> > > I also prefer to send complete html responses, for SEO and general
> > > crawling benefits.
> > > One strategy I used was to craft views to output different kinds of
> > > rows. For instance, you've got you main content row, and you can also
> > > have "block" rows, to pepper your html page with.
> > > The list fonction can then handle those different row types and
> > > generate proper html.
> > >
> > >
> > > --
> > > Robin
> > >
> >
>