xkxd / gulp-html-partial Goto Github PK
View Code? Open in Web Editor NEWGulp plugin for including HTML files into each other
License: MIT License
Gulp plugin for including HTML files into each other
License: MIT License
Expected:
<p>Lorem ipsum dolor sit amet <span class="underline">consectetur</span> et <span class="underline">dipiscing</span> elit.</p>
Output:
<p>Lorem ipsum dolor sit amet <span class="underline">consectetur</span> et <span class="underline">dipiscing</span>elit.</p>
Any chance to fix this?
I've defined partial _foot.html
that contains only </body></html>
in it. If you try to build you project with such partial, you'll get a crash with the following trace:
/Users/rpeshkov/Developer/markup/rpeshkov.net/node_modules/html/lib/html.js:466
var tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length -1].match(/<\s*(\w+)/);
^
TypeError: Cannot read property 'match' of undefined
at Object.style_html [as prettyPrint] (/Users/rpeshkov/Developer/markup/rpeshkov.net/node_modules/html/lib/html.js:466:101)
at injectHTML (/Users/rpeshkov/Developer/markup/rpeshkov.net/node_modules/gulp-html-partial/gulp-html-partial.js:132:36)
at getPartial (/Users/rpeshkov/Developer/markup/rpeshkov.net/node_modules/gulp-html-partial/gulp-html-partial.js:89:20)
at tags.map (/Users/rpeshkov/Developer/markup/rpeshkov.net/node_modules/gulp-html-partial/gulp-html-partial.js:117:44)
However, if you slightly change this partial to something like <b></b></body></html>
then it works fine.
Is there a way to implement variables that enable me to create an active nav on each page?
Hi!
This isn't really an issue needing resolve, however I thought this would be super useful for others.
Love this little Gulp plugin - great for HTML management when the introduction of something like Mustache or Handlebars isn't an option.
I came across an issue when using this plugin and useref. All it took to fix it was to clean up the line endings after you've run it. Suspect this is likely to be more of a problem for those with a windows / sublime combo.
However, install gulp-line-ending-corrector, require and use it in your task like this:
gulp.task('html-partials', function () {
return gulp.src('app/html/*.html')
.pipe(htmlPartial({
basePath: 'app/html/'
}))
.pipe(lec({verbose:true, eolc: 'LF', encoding:'utf8'})) // clean up line endings for useref to find flags
.pipe(gulp.dest('dist'))
.pipe(livereload());
});
Bosh! useref works just fine and dandy and able to find your flags. Hope it helps others along the way!
Hi
Moving over from grunt to gulp and replacing grunt-bake with this task
i have the following partial
<partial src="accordion.html" identifier="first"></partial>
accordion.html is
<h2 class="c-accordion__heading heading js-accordion-heading" id="@@identifier-accordion-header-1" role="tab" aria-controls="@@identifier-accordion-panel-1" aria-selected="false" aria-expanded="false">Accordion header 1</h2>
output
<h2 class=" js-accordion-heading" id="first-accordion-header-1" role="tab" aria-controls="@@identifier-accordion-panel-1" aria-selected="false" aria-expanded="false">Accordion header 1</h2>
Does it not work on multiple instances of a variable?
Hi.
At first thanks for your work. Gulp-html-partial is what I looked for.
When I tried to check how the plugin works (https://runkit.com/npm/gulp-html-partial), there error occurred โ "SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode". I hope you'll have time to check it.
How to process only changed files? Can someone provide an example task? Thanks.
Would it be possible to get a partial via a variable like so?
Main file -
<body>
<partial src="child.html" content-partial="content.html" ></partial>
</body>
child.html
<div class="child-component">
<partial src="@@content-partial" ><partial>
</div>
content.html
<p>Lorem ipsum...<p>
<p>Dolor sit amet...<p>
This functionality would be really helpful when making reusable templates with nested partials!
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.