I'm currently working on a ghost theme and I had so great ideas, but I'm messing around with the handlebars template engine you choose.
I'm missing some features with the current engine:
Why are these features important?
Being able to extend blocks and append / prepend code would be so great to become child-theme compatible.
And with the variables I wanted to create a small config file for my theme, but it looks like the current engine doesn't support the definition of variables inside the template files. It could've been a great workaround until themes can extend the admin panel.
Is there a special reason why you used handlebars as your template engine and not something like "jade" which even is the default engine for express?
I'm not a fan of jade. I don't think it should be possible to put logic in templates at all, it leads down the path of PHP in your wordpress themes.
We should focus on making good helpers in our theme api to accomplish the things you want to do.
Right now, your two bullet points should be covered by using partials, theme helpers ghost.registerThemeHelper and filters. Admittedly, we haven't got good documentation on those at the moment.
I think you'll find you can accomplish a lot with logic less templates, just have to learn more about handlebars.
jade doesn't put much logic into the templates. Not much more than handlebars. You can't execute wild nodeJS stuff when you don't provide it as template attributes like you do with handlebars.
+1 for jade. It makes writing html much easier plus block extensions would be super useful.
There have already been a few closed tickets on the topic already. This isn't really the place for debating it, so I made a Google+ post for discussion. I don't think this is as limiting as it appears, but It may also be possible to use a plugin to get jade working eventually.
@BiosElement +1 :trophy: :rainbow:
FYI. There are blocks in the version of Express middleware we are using.
Bikeshedding, it's real.
I know that there are blocks in handlebars!
But I can't extend a block of my parent template!
What I want (if it would be handlebars):
<!-- default.hbs -->
{{block "css"}}
<link rel="stylesheet" href="/stylesheets/style.css" />
{{/block}}
<!-- post.hbs -->
{{!< default}}
{{#content "css" append}}
<link rel="stylesheet" href="/stylesheets/post.css" />
{{/content}}
resulting in
<link rel="stylesheet" href="/stylesheets/style.css" />
<link rel="stylesheet" href="/stylesheets/post.css" />
What I would have to do at the moment:
<!-- default.hbs -->
{{{block "css-prepend"}}}
<link rel="stylesheet" href="/stylesheets/style.css" />
{{{block "css-append"}}}
<!-- post.hbs -->
{{!< default}}
{{#content "css-append"}}
<link rel="stylesheet" href="/stylesheets/post.css" />
{{/content}}
And what I still cant do: replace all the css, and define custom variables.
That seems like a contrived example. Usually things in your layout (default.hbs) are global, so why would style.css not just be outside of the block. Leaving you able to just use the css block like before?
<!-- default.hbs -->
<link rel="stylesheet" href="/stylesheets/style.css" />
{{block "css"}}
<!-- post.hbs -->
{{!< default}}
{{#content "css"}}
<link rel="stylesheet" href="/stylesheets/post.css" />
{{/content}}
You are searching for functionality that is just _different_ in handlebars, not necessarily missing. Learn something new, it's good for you.
We put a lot of time, thought, and testing into the decision to use handlebars. We've been trying it with the 200+ VIPs since July, many of whom were WP theme devs who wanted to get in on the action nice and early. The response we had was overwhelmingly positive.
So far, the comments I'm seeing here are all due to a lack of knowledge around handlebars, and it's definitely true that we need to provide more education, better examples, and in depth tutorials to help support theme developers.
But we only launched on Monday.
The thing is that you wouldn't have to create this functionality by yourself, because it could be provided by the engine. Basically I just wanted to know if there was a special reason, that you selected handlebars as your (primary) templating engine.
@jgable Why would I want to replace a block you basically ask? The main reason is the feature to create child-themes. The default.hbs would extend the default.hbs of the parent theme and replace the stylesheets, because maybe this is just the thing i want to do: replace the stylesheet with my new, fancy one, but keep the basic HTML structure of the parent theme
I know how to use handlebars AND jade! I just say that jade would bring more functions to template designers WITHOUT implementing these features yourself in the ghost core.
@ErisDS Did you ever talked about using jade or another engine? Or was it just because most of your team had no experience with other engines?
Your use case of 'child themes' is exactly the kind of over-complication we're trying to avoid.
Yes, we looked at a lot of different templating engines, as I said in my previous reply:
We put a lot of time, thought, and testing into the decision to use handlebars.
We wanted to create the best possible theme API, and we believe we have done this.
Jade would not have been a good choice because it would have required that theme developers learn this very different way of writing HTML. That's a barrier to entry because it's not what people are used to. It doesn't make 'writing HTML easier' at all, it makes writing HTML something you have to learn to do all over again - it's completely over the top and not what we were looking for.
Wait, there is consolidate, right?
All Template engine included
https://github.com/tj/consolidate.js/
@buckle2000 You're like, 5 years too late mate.
Most helpful comment
+1 for jade. It makes writing html much easier plus block extensions would be super useful.