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

Use a different template engine #1131

Closed
CBeloch opened this issue Oct 16, 2013 · 13 comments

Comments

@CBeloch
Copy link

commented Oct 16, 2013

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:

  • block extension (append and prepend to blocks)
  • variables

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?

@jgable

This comment has been minimized.

Copy link
Member

commented Oct 16, 2013

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.

@CBeloch

This comment has been minimized.

Copy link
Author

commented Oct 16, 2013

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.

@nilgradisnik

This comment has been minimized.

Copy link

commented Oct 17, 2013

+1 for jade. It makes writing html much easier plus block extensions would be super useful.

@BiosElement

This comment has been minimized.

Copy link

commented Oct 17, 2013

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.

@gotdibbs

This comment has been minimized.

Copy link
Member

commented Oct 17, 2013

@BiosElement +1 🏆 🌈

@jgable

This comment has been minimized.

Copy link
Member

commented Oct 17, 2013

FYI. There are blocks in the version of Express middleware we are using.

Bikeshedding, it's real.

@CBeloch

This comment has been minimized.

Copy link
Author

commented Oct 17, 2013

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.

@jgable

This comment has been minimized.

Copy link
Member

commented Oct 17, 2013

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.

@ErisDS

This comment has been minimized.

Copy link
Member

commented Oct 17, 2013

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.

@ErisDS ErisDS closed this Oct 17, 2013

@CBeloch

This comment has been minimized.

Copy link
Author

commented Oct 17, 2013

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?

@ErisDS

This comment has been minimized.

Copy link
Member

commented Oct 17, 2013

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.

@buckle2000

This comment has been minimized.

Copy link

commented Jun 21, 2018

Wait, there is consolidate, right?
All Template engine included
https://github.com/tj/consolidate.js/

@BiosElement

This comment has been minimized.

Copy link

commented Jun 21, 2018

@buckle2000 You're like, 5 years too late mate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.