Skip to content

Instantly share code, notes, and snippets.

@CharlotteGore
Last active December 25, 2015 20:09
Show Gist options
  • Save CharlotteGore/7032514 to your computer and use it in GitHub Desktop.
Save CharlotteGore/7032514 to your computer and use it in GitHub Desktop.
var test = dom('<a href="#products/{{_links.self.products}}" alt="something" rel="{{rels.products}}" />Check out all the {{products}}</a>');
var props = [];
Array.prototype.forEach.call(test.els[0].attributes, function(attr){
var tokens = attr.nodeValue.split(/\{\{|\}\}/);
if(tokens.length > 1){
var i = 0;
tokens.forEach(function(t){
i++;
if(++i % 2 === 0){
props.push({
attribute : attr.name,
raw : attr.nodeValue,
tokens : tokens
});
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment