Created
May 25, 2017 09:23
-
-
Save JulienRAVIA/d93a84bf7ed1b503dc22a004c433e928 to your computer and use it in GitHub Desktop.
Emmet filter for PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"php": { | |
"filters": "php", | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment