quangv / hulk-hogan

Hogan.js for Express with support for Template Partials.
MIT License
37 stars 2 forks source link

Please help, how do you include partials/layout in express 3 #14

Open lundin opened 12 years ago

lundin commented 12 years ago

Hi, thanks for the work with hulk-hogan,

But i am unable to get the desired result by following the guide here (expresss 3.0):

app.js

app.get('/', function(req,res){

res.render('create', {title: 'Deck was successfully created',what:'Pontus' });

})

in view, create.hulk hello {{what}} {{> footer}}

Displays {{what}} correctly, what about footer ?? doesn't get included, i have a footer.hulk and what about the layout.hulk with {{{body}}} i have that as well it doesn't wraps the create.hulk template.

Thanks.

kohlikohl commented 12 years ago

I am battling with the same issue at the moment.

According to the expressjs migration guide the concept of layout has been removed from express. This means that whatever templating language you are using needs to take ove the role of filling data into a layout.

Now, according to this comment on stackoverflow hogan.js supports template inheritance.

I have tried this with hulk-hogan, couldn't get it to work yet though.

lundin commented 12 years ago

Hi, Yeah, the template thing in Express is at the moment a bit messy and unclear, it is also hard to know if the consolidate.js project is covering the recent hogan and partials or hulk-hogan vs hulk-express etc but every post i can find basically says people are having success with the {{{body}}} tag in the layout so i am missing the obvious or something=)

In the end i dont think i will go with rendering on the server-side anyway but just send json to the client (at least that is what i find node really god at) but nice to know if it works.

Hopefully somone can chime in here.

quangv commented 12 years ago

Hey Lundin,

sorry for the late reply, I do not currently use Express 3.0, what is your Express config look like?

Is footer.hulk file in the same directory as your create.hulk ? And are you defining that directory for Express ?

app.set('views', __dirname + '/views');

Can you link to the the layout.hulk and {{{body}}} example you are referencing? I am unfamiliar with those.

At this point, I do not know 100% if partials works on Express 3.0.

pvencill commented 11 years ago

Doesn't look like it, I'm having the same issue and in my case, the partia lis in the same directory, and the registration appears correct otherwise. If I maek a single file (no partials) it works correctly. If I make a view w/ partials then everything not in the partial renders.

quangv commented 11 years ago

@pvencill

Oic, thanks for confirming it doesn't work in Express 3.0 ... I'll have to take some time next week/weekend (or whenever I'm free) to checkout Express 3.0 and see if I can get partials to work...

Until then, checkout MMM https://github.com/techhead/mmm that might have Partials working on Express 3.0 currently.

mischah commented 11 years ago

I would also love to use partials with »Hulk Hogan« and »Express 3.0« …