My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
ZenCodingAPI  
Brief description of Zen Coding API
Updated Jun 19, 2009 by serge....@gmail.com

This document in early development stage and can be changed at any time

Profiles

Profiles are set of properties that defines how expaned abbreviations should output. There are number of predefined profiles in Zen Coding: plain, html, xhtml, xml.

How to use profiles:

from zencoding import zen_core as zen

print(zen.expand_abbreviation('div#header>p', 'html', 'xml'))

The last attribute is profile name, default value is plain.

Creating your own profile

In order to create your own profile you need to call zen_core.setup_profile(name, options), where options is a dictionary with the following properties:

  • tag_case — Tag's name case. Possible values are 'upper' and 'lower' (<IMG /> or <img />). Default value: 'lower'.
  • attr_case — Tag attribute's name case. Possible values are 'upper' and 'lower' (<a HREF=""> or <a href="">). Default value: 'lower'.
  • attr_quotes — Attribute value's quotes. Possible values are 'single' and 'double' (<a href=''> or <a href="">). Default value: 'double'.
  • tag_nl — Print each tag on new line. Possible values are True, False, 'decide'. The last value means that newline character will be printed only if current tag is block level (e.g. <p>, <div>, <blockquote>). Default value is 'decide'.
  • place_cursor — Print cursor (pipe characer: |) to the output. Possible values are True and False. Default value is True.
  • indent — Indent child tags. Possible values are True and False. Default value is True.
  • self_closing_tag — Add self-closing character for empty elements. Possible values are True, False, 'xhtml' (<img/>, <img> and <img /> respectively). Default value: 'xhtml'.

Example:

from zencoding import zen_core as zen

zen.setup_profile('my_profile', {'tag_case': 'upper', 'place_cursor': False}))
print(zen.expand_abbreviation('div#header>p', 'html', 'my_profile'))

If you omit some of the properties, default value will be used.


Sign in to add a comment
Powered by Google Project Hosting