var Handlebars = require('handlebars');
var _ = require('underscore');
var less = require('less');
module.exports = function (config) {
var sourceHead =
'\n' +
'{{#if debug}}' +
'\n' +
'\n' +
'{{else}}' +
'\n' +
'{{/if}}';
var sourceBody =
'\n' +
'\n' +
'\n' +
'\n' +
'\n';
var templateHead = Handlebars.compile(sourceHead);
var templateBody = Handlebars.compile(sourceBody);
var getPreviewHTML = function (options, content, callback) {
var html = replaceMarkers(options, content, templateHead(options), templateBody(options));
callback(null, html);
};
var replaceMarkers = function (options, html, styleMarkerReplacement, jsMarkerReplacement) {
function replace(marker, replacement) {
var regExp = new RegExp('');
if (html.match(regExp)) {
html = html.replace(regExp, replacement);
} else {
html = html.replace('', '\n');
}
}
console.log('martker options',options);
/* markers:
[type]_[collection]_[name]_[attribute]
script ->
style ->
template_[collection]_[nameX]_[attribute]_context_[collection]_[name]_[attribute]
template -> put /content/collection/nameX/attribute thru handlebars.. context=collection/name/attribute and include
[type]_[collection]_[name]
script ->
contains all type='script' attributes concatenated based on 'order'
style ->
contains all type='style' attributes concatenated based on 'order'
*/
replace(options.collection + '_' + options.name + '_' + 'style_marker', styleMarkerReplacement);
replace(options.collection + '_' + options.name + '_' + 'behaviour_marker', jsMarkerReplacement);
return html;
};
return {
getPreviewHTML: getPreviewHTML,
_replaceMarkers: replaceMarkers
};
};