bdadam / rollup-plugin-html Goto Github PK
View Code? Open in Web Editor NEWImport HTML files as strings in rollup build
License: MIT License
Import HTML files as strings in rollup build
License: MIT License
<!-- home.html -->
<div class="${homeStyl.title}"> <!-- <= Note! -->
Home
</div>
// home.css
.title {
color: red;
}
// home.js
import homeStyl from './home.css';
import homeTpl from './home.html';
document.querySelector('#home').innerHTML = ??
// home.js
import homeStyl from './home.css';
document.querySelector('#home').innerHTML = `
<div class="${homeStyl.title}">
Home
</div>
`;
Is anyone home? Can we get a update of dependencies?
Hello,
This issue isn't the end of the world, as the UTF8 spec says a BOM zero width and non line breaking - but it would be nice if it didn't include the file BOM in the exported template string.
Picture of an example, converted to ANSI to show the BOM
VSCode shows it as an unknown character even when in UTF8 mode, which is why I noticed it.
Trying to import a file that contains the following results in an error:
<img src="foo.png"> <!-- Valid HTML -->
[!] (plugin at position 5) SyntaxError: Expected corresponding JSX closing tag for <img> (68:20)
src\foo.html (68:20)
SyntaxError: Expected corresponding JSX closing tag for <img> (68:20)
HTML does not require closing tags on many elements, including img, input, etc.
So, this shouldn't be requiring this.
Hi, could you provide some real examples. As I understand I can do something like
import htmlTemplate from './template.html';
document.body.innerHTML = htmlTemplate;
Can you use some kind of variables in template? If it returns an ES6 template string, then you could be able to call htmlTemplate(data);
When using a self-closing tag in the included template, the slash is lost in the output, For example:
template.html
:
<div>
<router-view />
</div>
control.js
:
import template from './template.html';
Result:
var template = "<div>\r\n <router-view>\r\n</div>";
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.