Skip to content

Instantly share code, notes, and snippets.

@JulienRAVIA
Created May 25, 2017 09:23
Show Gist options
  • Save JulienRAVIA/d93a84bf7ed1b503dc22a004c433e928 to your computer and use it in GitHub Desktop.
Save JulienRAVIA/d93a84bf7ed1b503dc22a004c433e928 to your computer and use it in GitHub Desktop.
Emmet filter for PHP
emmet.require('filters').add('php', function process(tree) {
_.each(tree.children, function(node) {
// define variable name
if (node.name() == 'data' && node.parent == ''){
node.start = '\\$this->request->data';
}else{
node.start = (node.parent == '' ? '\\$' : '') + node.name();
}
// define object keys
var className = node.attribute('class');
if (className) {
node.start += className
.split(' ')
.map(function(c) {return "['" + c + "']";})
.join('');
}
node.start += node.children.length == 0 ? '' : '->';
node.end = '';
process(node);
});
return tree;
});
...
"php": {
"filters": "php",
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment