Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions lib/htmlincludes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ var tagRegex = /<include([^>\/]*)\s?\/?>/g;
var attrRegex = /([a-z]+)=('([^']*)'|"([^"]*)"|([^\s]*))/g;

function parseIncludeTags(docs, html, htmlAttribute) {
if(typeof html != 'string') {
return html;
}

// find include tags
return html.replace(tagRegex, function(tag, tagAttrs) {
var attributes = {};
if (typeof html === 'string') {
html = [].concat([html]);
}
return html.map(function (snippet) {
return snippet.replace(tagRegex, function(tag, tagAttrs) {
var attributes = {};

// find attributes
var groups = tagAttrs.match(attrRegex);
for(var i = 0; i < groups.length; i++) {
var p = groups[i].split(/=/);
if(p[1]) {
attributes[p[0]] = p[1].replace(/^["']/, '').replace(/["']$/, '');
// find attributes
var groups = tagAttrs.match(attrRegex);
for(var i = 0; i < groups.length; i++) {
var p = groups[i].split(/=/);
if(p[1]) {
attributes[p[0]] = p[1].replace(/^["']/, '').replace(/["']$/, '');
}
}
}

// find the included document for these attributes
return findDocByAttributes(docs, attributes, htmlAttribute);
// find the included document for these attributes
return findDocByAttributes(docs, attributes, htmlAttribute);
});
});
}

Expand Down