ludovicchabant / PieCrust

A simple PHP website engine and static file generator.
http://bolt80.com/piecrust
Other
239 stars 43 forks source link

issues with Mustache template engine #150

Open BlackScorp opened 10 years ago

BlackScorp commented 10 years ago

Hello guys i like the mustache template engine but i cannot use it with piecrust.

1) Problem when i enable mustache as template engine, Piecrust still search for .html files i gues it could be fixed when i add here the template engine default extension https://github.com/ludovicchabant/PieCrust/blob/master/src/PieCrust/Page/PageRenderer.php#L61 instead of .html

2) i cannot use partials {{>header}} {{{content}}} {{>footer}}

only content is displayed. i think the Problem is on this place

https://github.com/ludovicchabant/PieCrust/blob/master/src/PieCrust/TemplateEngines/MustacheTemplateEngine.php#L65

mustache is not configured at all, the engine does not know anything about template paths or cache folder etc

ludovicchabant commented 10 years ago

Hi there!

Sorry you're having trouble... to be fair, I haven't used Mustache templates in years, and I'm pretty sure nobody else has either :) So yeah, it's possible it's just broken. Some comments:

  1. PieCrust 2.0 is going to be better on that front, but for now it's by design. If you specify layout: blah in your page header, PieCrust will only look for layout.html. You would need to specify layout: blah.mustache for PieCrust to look for other extensions.
  2. I probably just haven't tried partials at all :) I'll take a look at your pull request, thanks.
BlackScorp commented 10 years ago

well no problem iam going to fix this for my needs, PieCrust is at least then one Static Site generater which even support Mustache. My Pullrequest is not working currently, i will make a new one as soon as i fixed the error

BlackScorp commented 10 years ago

ok my last pullrequest fixed the problems,

right now you can define layout: something.mustache

and something.mustache can have following code

{{>partials/header}}
{{{content}}}
{{>partials/footer}}

and your header.mustache can render all stuffs e.g. {{site.title}} to make it work like twig i have to create Plugins and enable them so you can use things like

{{somelink | prettify }} or if you dont like {{{content}}} (3 braces) as raw output {{content | raw}} could be also added, could you accept the PR as soon as possible? so i can upgraid my version on the server

ludovicchabant commented 10 years ago

At last I started looking at the pull requests, but there's a lot of stuff in there, some of it not super clean unfortunately (like for some reason lots of files getting their mod changed?). Also TravisCI says the tests fail on it so I'll have to try it myself... I'll comment over there when I've got some info, thanks.