Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justinbmeyer
Created September 25, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinbmeyer/6eb86e2836d3b4ec7f0dbe832ce9e4fd to your computer and use it in GitHub Desktop.
Save justinbmeyer/6eb86e2836d3b4ec7f0dbe832ce9e4fd to your computer and use it in GitHub Desktop.
var canViewParse = require("can-view-parser");
var someSortOfEach = /\{\{#\s*each\(/
var eachMatch = /\{\{#\s*each\(\s*([\w\.\(\)]+)\s*\)\s*\}\}/;
function processStache(source) {
canViewParse(source, {
start: function(){},
end: function(){},
close: function(){},
attrStart: function(){},
attrEnd: function(){},
attrValue: function(){},
chars: function(){},
comment: function(){},
special: function(){
console.log("--got special",arguments);
},
done: function(){}
});
}
var scriptRegExp = /<script\s([^>]+)>([\s\S]*?)<\/script>/ig;
module.exports = function(fileInfo, api, options) {
console.log(fileInfo.path)
fileInfo.source.replace(scriptRegExp, function(whole, attrs, content){
processStache(content);
})
/*
var foundSomeMatch = false;
fileInfo.source.replace(eachMatch, function(whole, variable){
foundSomeMatch = true;
console.log("updating ",fileInfo.path);
console.log(" ",variable);
return whole;
});*/
//var hasEach = eachMatch.test(fileInfo.source);
//if(hasEach) {
// console.log("discovered! ",fileInfo.path);
//}
return fileInfo.source;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment