Joker / jade

Jade.go - pug template engine for Go (golang)
BSD 3-Clause "New" or "Revised" License
354 stars 37 forks source link

Template parse error: unexpected "title" in block clause #11

Closed xDarkicex closed 8 years ago

xDarkicex commented 8 years ago

each is undefined, for is undefined when trying to do functions in pug template.

Joker commented 8 years ago

Can you show me not working parts of that template?

xDarkicex commented 8 years ago

https://gist.github.com/xDarkicex/13204e6d61a8174d352641c4e4fe923b

The commented out parts are the broken Bits, I have included the render go code if I m=am doing this wrong.

Also how do you do a partial if I only have a include in a few pages I dont thing I can pass nil to funcmap deal

extends ../layouts/application.pug

block main-content
    div.container-fluid
        h1 New Post
        //- include "_form.pug"
Joker commented 8 years ago

Here's a working example with includes and extends. You can implement and attach other Funcs the same way. If you uncomment an extends in Gist/index.pug the blocks will work.

xDarkicex commented 8 years ago

I had too add a "." to all my var from my object and my each in func didnt work but range did, seems your engine doesn't 100% convert jade too go templates I had to sort of mix and match the two to get it working properly.

Joker commented 8 years ago

At this moment the engine 100% converts from Jade to Go Template. So Javascript code works as is only if it's emulated on FuncMap, because Go Template does not support such constructions as each, unless, case etc.

xDarkicex commented 8 years ago

I see, I got it all figured out now thank you, now that I understand I see why the funcmap is needed, I might suggest covering custom functions in your example and or possibly mentioning it in the readme. Thank you for your time.

Joker commented 8 years ago

Ok, it's a good idea, thank you.