Open pulse00 opened 11 years ago
There are two options how to do this:
dw
and the following content: <div wicket:id="${id}" class="${class}"></div>
. You can use it as follows: dw#some-id.some-class
. But it’s a static snippet, e.g. you can’t add new attributes, you have to create new snippet for each element etc.div#:foo
e.g. prefix ID attribute with :
. You can then find all nodes whose ID values starts with :
and update attribute name. Filters are written in JavaScript and should be placed at Extensions dir.You can take a look how user used custom filter to use abbreviations in PHP: https://github.com/sergeche/emmet-sublime/issues/365
@sergeche thanks a lot for your feedback. The examples you posted should get me started to work with filters, but i can't find the Extensions directory to put the JS filters. I've been searching in the plugins
and features
folders of the eclipse instance where emmet is installed.
Any hint where the Extensions
directory is located?
Check out Emmet section in Eclipse preferences
I've tried to get the PHP example from sergeche/emmet-sublime#365 working in eclipse, the following way:
emmet
directory in the eclipse folder and select this as the extension dir in the emmet
eclipse preferencesphp.js
javascript file in the emmet
directory with the following content: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;
});
snippets.json
file in the emmet
dir with the following content:{
"php": {
"filters": "html, php"
}
}
Now when i open a foo.php
file in eclipse and expand the abbreviation this>Model>data.Model.id
, i see the regular html
output of emmet:
<this>
<model>
<data class="Model id"></data>
</model>
</this>
It seems emmet/eclipse doesn't pick up the filter i've placed in the extensions dir. Is there an .options
file directive so i can launch eclipse in -debug
mode and see what's going on under the hood when expanding abbreviations?
Try to call php
filter explicitly, e.g. this>Model>data.Model.id|php
. Eclipse doesn’t provide a common interface for detecting syntaxes so it has to be programmed individually for each syntax/plugin.
@sergeche nope, also with the explicit filter syntax, the expanded text is the same as before.
I want add a snippet like -e:{sometext} in html and want this <?php _e("sometext");?>${cursor} is this possible??
In eclipse.
@sarwarcse yes, it’s possible
@sergeche Would you please show me a sample. How can i do this?
@sarwarcse There are hints on the very fist page of this very repo: https://github.com/emmetio/emmet-eclipse#plugin-overview
And lots of docs which you already read, right?
Yes I have read and tried into Zend Studio 10. But I didn't get what I need.
Just open Preferences > Emmet
Yes I have added other snipped but can't added this type of snipped. Which is like e:{THE TEXT WHAT I WANT} to <?php _e("THE TEXT WHAT I WANT");?>${cursor}
<?php _e(\"${child}\");?>${cursor}
http://docs.emmet.io/customization/snippets/#variables
Many many thanks for your reply but I so sorry , its not working.
OK, I’ll check it out. Eclipse might have outdated Emmet core
There's a settings page called
Abbreviations
, but i'm not sure if what i'm trying to do is possible with it.We're using a framework which has custom XHTML attributes, e.g.
<div wicket:id="foo" class="bar"/>"
, where thewicket:id
attribute is used by the framework and will be removed from the rendered HTML.Is it possible to create a custom abbreviation which inserts a
wicket:id
attribute inside an html tag?For example
div.bar?foo
will be expanded to<div wicket:id="foo" class="bar"></div>
, using the?
character as the token for the custom abbreviation.