Hugo: Move internal shortcodes and templates into individual files

Created on 27 Feb 2018  路  3Comments  路  Source: gohugoio/hugo

Hello,

At the moment, all the internal shortcodes and templates are inlined in a single file: template_embedded.go.

Proposal

Move the shortcodes and templates from:

hugo/tpl/tplimpl/template_embedded.go

to:

- hugo/tpl/tplimpl/
    template_embedded.go
- hugo/tpl/tplimpl/internal_shortcodes/
    figure.html
    ..
- hugo/tpl/tplimpl/internal_templates/
    opengraph.html
    ..

The template_embedded.go will still be there, but now instead of inlining all the code in there, it will loop through all the files in internal_shortcodes and internal_templates and read those in. That should be possible, right?

Advantages

  • Easier to read internal shortcodes and templates as they can now be nicely indented.
  • Supporting editors can now show the syntax highlighting appropriately for the Go templates.
  • Clean git history specific to each shortcode and template.

Disadvantages

??

Enhancement

Most helpful comment

That should be possible, right?

Yes, but it sadly involves an extra "go generate" build step. But I think it's still worth it, so I will do it.

All 3 comments

Another advantage: Easier to unit test.

That should be possible, right?

Yes, but it sadly involves an extra "go generate" build step. But I think it's still worth it, so I will do it.

Awesome! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digitalcraftsman picture digitalcraftsman  路  3Comments

VoidingWarranties picture VoidingWarranties  路  3Comments

moorereason picture moorereason  路  3Comments

mumblecrunch picture mumblecrunch  路  3Comments

antifuchs picture antifuchs  路  3Comments