question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Built in support for template engines

See original GitHub issue

Is your feature request related to a problem? Please describe. Yes. Trying to use anything but html for your markup doesn’t quite work at the moment.
I’ve been trying to develop a Pug plugin and I got stuck.
There were a few tickets (#842 #528 #17 ) closed, but I don’t think the issue is solved.
By making a plugin using transformIndexHtml you would still need an index.html. You can’t have a structure like this for example:

_main.pug
index.pug << extends _main.pug
about/
  |-- index.pug << extends _main.pug
vite.config.js

Snowpack had a similar issue where the transformed files were not routed and they were able to fix it, any chance we could get some ideas from it?

Describe the solution you’d like Being able to use template engines like handlebars, mustache or pug by just installing a plugin package or the engine package.

Describe alternatives you’ve considered Couldn’t really find a solution to this.

Additional context I also made a demo repo if that helps.
Unfortunately templating seems to be something left behind by most tools. If all you wanna do is make a website that is mostly HTML and CSS you shouldn’t need a huge JS bundle.
I would love to help make this happen, if anyone can point me in the right direction that would be much appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
davay42commented, Feb 3, 2021

@yyx990803 The use case is the same as vitepress and other SSGs. It’s a way to generate fast and SEO-proof website with multiple pages that have their rather complex scripts built with vite.

I fell in love with pug and stylus while working with SFCs in vite. But then I want to have just a couple of pages around my base app page? Think about about us and pricing pages. For now we can write them only with plain html and manually add to the multi-page list on the Rollup config. But imagine if we had an option to have a whole structure of templates with rather complex apps built just for each page. May be it’s too much for one tool? 🤷‍♂️

I’ve played around with the transformIndexHtml() and could make pug templates somehow working, but finally moved to 11ty.js to make this work and use vite to build just the libs that will be manually included into those pages as scripts. So every tool does it’s own job ) But may be once there will be that universal tool for vue 3. May be new Nuxt will do that?

3reactions
lubomirblazekczcommented, May 2, 2021

https://github.com/alexlafroscia/vite-plugin-handlebars/issues/39#issuecomment-817306337 something similiar was discussed here couple of days ago, regarding different extention then .html

Agree that built-in support is not really what is needed, but better support so this can be done with plugins is. Template engine plugins could be then added here https://github.com/vitejs/awesome-vite#plugins 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using template engines with Express
Some popular template engines that work with Express are Pug, Mustache, and EJS. The Express application generator uses Jade as its default, but...
Read more >
Template Engines for Spring - Baeldung
Discover Spring-compatible template engines and see simple examples. ... Spring application and an application built using Spring Boot.
Read more >
What are template engines? - Educative.io
Template engines are mostly used for server-side applications that are run on only one server and are not built as APIs. The popular...
Read more >
Template engines
Included with Groovy are several template engines: ... The template engine provides several support methods that will help you render ...
Read more >
Top Express.js template engines for dynamic HTML pages
It is built on the mustache templating engine, so they share some similarities. There are a number of npm packages available for compiling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found