Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inheritance doesn't work #244

Open
kflu opened this issue Apr 12, 2016 · 0 comments
Open

inheritance doesn't work #244

kflu opened this issue Apr 12, 2016 · 0 comments

Comments

@kflu
Copy link

kflu commented Apr 12, 2016

The inheritance doesn't work as specified here.

Having three template files:

{{! header.mustache }}
<head>
  <title>{{$title}}Default title{{/title}}</title>
</head>
{{! base.mustache }}
<html>
  {{$header}}{{/header}}
  {{$content}}{{/content}}
</html>
{{! mypage.mustache }}
{{<base}}
  {{$header}}
    {{<header}}
      {{$title}}My page title{{/title}}
    {{/header}}
  {{/header}}

  {{$content}}
    <h1>Hello world</h1>
  {{/content}}
{{/base}}

Run hulk from the command line (something like this, you get the idea):

npm install hogan.js
cat "var Hogan = require('hogan.js');" > script.js
hulk *.mustache >> script.js
cat "templates['mypage'].render()" >> script.js

Run with node: node script.js. The rendered result is empty string.

I noticed that the in hulk compiled JS script, templates['mypage'] correctly references a partial called 'base':

> templates['base']
{ r: [Function],
  c: undefined,
  options: {},
  text: '',
  partials: {},
  subs: { header: [Function], content: [Function] },
  buf: '' }
>
> templates['header']
{ r: [Function],
  c: undefined,
  options: {},
  text: '',
  partials: {},
  subs: { title: [Function] },
  buf: '' }
>
> templates['mypage']
{ r: [Function],
  c: undefined,
  options: {},
  text: '',
  partials: { '<base11': { name: 'base1', partials: [Object], subs: [Object] } },
  subs: {},
  buf: '' }

But it seems there is still something missing to connect the dots.

node version: v5.6.0
hogan.js version: 3.0.2
hulk version: 3.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant