michelangelo icon indicating copy to clipboard operation
michelangelo copied to clipboard

Twig support?

Open ydmitry opened this issue 7 years ago • 4 comments

How can I enable twig templates markup using this KSS theme?

When I write: // Markup: example.twig ...it writes file name as is "example.twig"

ydmitry avatar Sep 27 '17 13:09 ydmitry

@ydmitry This is just a theme on top of kss-node. This is what their docs says:

Instead of using inline HTML markup, you could point at a separate file that contains your HTML. kss-node supports either a plain *.html file or a Handlebars *.hbs file. The kss-node generator will search for the markup file in any of the --source folders.

You can find that here: github.com/kss-node/kss/blob/spec/SPEC.md.

JordyPouw avatar Sep 27 '17 14:09 JordyPouw

Do you mean I need to generate my examples from twig to HTML separately from KSS and use Markup: compiled-example.html ?

KSS node repository contains builder that can support twig: https://github.com/kss-node/kss-node/tree/master/builder/twig , but as I see index.* file of the builder should be written in twig and builder.js should inherit KssBuilderBaseTwig... Maybe there is a possibility to add twig builder to this theme?

ydmitry avatar Sep 28 '17 04:09 ydmitry

@ydmitry I understand. Currently in the kss-config.json we reference to "node_modules/michelangelo/kss_styleguide/custom-template/" with the builder setting, which is just the handlebars template. So creating multiple custom templates is what I think that should happen, something like this:

  • "node_modules/michelangelo/kss_styleguide/custom-templates/hbs"
  • "node_modules/michelangelo/kss_styleguide/custom-templates/twig"

And then it should be possible to reference with the builder setting to the custom theme you want.

Sad news is that I currently don't have the time. But good idea to add later on. For now you can fork this repo and try it yourself if you need it now. I think if you write the index template with the twig syntax and replace the handlebars builder with the twig builder it would work.

JordyPouw avatar Sep 28 '17 09:09 JordyPouw

+1

dawidk92 avatar Feb 12 '18 14:02 dawidk92