Support for partial html files
See original GitHub issueCould you provide an example of how to use partials in the html files?
Describe the solution you’d like
It would be great if the boilerplate supported partials (includes) and used them in the index.html
file
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Partial render in HTML/JavaScript - Stack Overflow
I have some HTML files, and each one of them I want to partially render in another HTML file, for example header.html and...
Read more >The Simplest Ways to Handle HTML Includes | CSS-Tricks
The Simplest Ways to Handle HTML Includes · Use PHP · Use Gulp · Use Grunt · Use Handlebars · Use Pug ·...
Read more >How to Modularize HTML Using Template Engines and Gulp
Template engines are tools that help you break HTML code into smaller pieces that you can reuse across multiple HTML files.
Read more >How can you use a partial HTML file inside a template as a ...
As I tried to build this sort of “function”, I have create a partial file named phone.html that contains this very basic code:...
Read more >Partial views in ASP.NET Core | Microsoft Learn
A partial view is a Razor markup file ( .cshtml ) without an @page directive that renders HTML output within another markup file's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, thanks for the great boilerplate! I think adding a template engine (like mustache-loader or handlebars-loader for Webpack) could be great! On one hand I appreciate the simplicity of using pure HMTL, but in practice code splitting quickly becomes needed (for a shared navigation menu for example).
Concretely, that means we would write .hbs files (using Handlebars) instead of .html files, gaining the benefits of using variables or includes.
Everything will be compiled into static HTML with webpack, no performance issue here.
I could look into that and send a PR, But it’s up to you @erickzhao if you’re willing to drop pure HTML 😃
Edit : And if I’m not wrong, this would be completely optional. Up to developers to create .html or .hbs files. So you get the best of both worlds 😃
@erickzhao so far here is what I’ve done to get something working. Now it doesn’t support variables which I think would be the next step (maybe using mustache-loader) but having the ability to split up repetitive code is a step in the right direction…
in webpack.config.common.js
in index.html
As I understand it the partial is relative to the file calling it and not the root. But this has allowed me to bring in common html snippets for multiple pages.