Siouss / zen-coding

Automatically exported from code.google.com/p/zen-coding
0 stars 0 forks source link

Request: method to specify language code for snippets #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently all snippets default to xml:lang="ru".  It would be very nice if 
there were a way to 
specify language codes without needing to edit the settings.py file.  For 
instance, some sort of 
placeholder that would automatically be replaced when the snippet was expanded, 
and could be 
set at run time by whatever plugin is managing the script.

For instance, if there were a zen_settings['language'] variable that could be 
set, I would be able 
to place this decision in the hands of the users for Espresso by adding an item 
to the 
Preferences.

Currently I either have to leave them defaulting to 'ru', or switch everything 
to some other 
language that is going to please some but not others.

One possible way to do this would be to implement placeholder variables in the 
snippets.  For 
instance, perhaps wherever a language code is needed ${language} is inserted.  
When the snippet 
is parsed, a regex looks for variables, and if there's a corresponding key in 
zen_settings the 
contents is inserted.

In the language example, the regex would find something along the lines of 
r'\$\{([a-zA-Z0-
9_]+)\}' and if match[1] existed and match[1] in zen_settings it would replace 
the placeholder 
with zen_settings[match[1]].

Or at least that's the best solution I could think of, but it's late so it 
might not be the most 
elegant solution to the problem.  :-)

Ian

Original issue reported on code.google.com by georgeth...@gmail.com on 4 Jun 2009 at 5:12

GoogleCodeExporter commented 8 years ago
Done. Now Zen Coding uses variables that can be overriden by user. These 
variables (see 
zen_settings['variables']) are inserted inside code snippets and expanded 
abbreviations at real-time. See my 
private branch: http://code.google.com/p/zen-coding/source/browse/

Original comment by serge....@gmail.com on 30 Jun 2009 at 4:51