mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Added an XML processing directive tag.
git-svn-id: svn://hamptoncatlin.com/haml/branches/edge@118 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
234606d83c
commit
7ea068eac1
5 changed files with 48 additions and 0 deletions
22
REFERENCE
22
REFERENCE
|
@ -289,6 +289,28 @@ is compiled to:
|
|||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
==== ?
|
||||
|
||||
The question mark character creates an XML processing directive (an XML
|
||||
prolog, a stylesheet link, or another format-specific directive). It's
|
||||
followed by the "target" of the directive, followed by any attributes
|
||||
of the directive. If the target is left out, it defaults to "xml." For
|
||||
example:
|
||||
|
||||
?{ :version => "1.0", :encoding => "UTF-8" }
|
||||
|
||||
is compiled to:
|
||||
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
|
||||
and
|
||||
|
||||
?xml-stylesheet{ :href => "stylesheets/rss.css", :type => "text/css" }
|
||||
|
||||
is compiled to:
|
||||
|
||||
<?xml-stylesheet href='stylesheets/rss.css' type='text/css' ?>
|
||||
|
||||
==== /
|
||||
|
||||
The forward slash character, when placed at the beginning of a line, wraps all
|
||||
|
|
|
@ -55,6 +55,11 @@ module Haml
|
|||
nil
|
||||
end
|
||||
|
||||
# Adds an XML processor direction to the buffer.
|
||||
def push_proc(target, attributes, tabulation)
|
||||
@buffer << "#{tabs(tabulation)}<?#{target}#{build_attributes(attributes)} ?>\n"
|
||||
end
|
||||
|
||||
# Takes the various information about the opening tag for an
|
||||
# element, formats it, and adds it to the buffer.
|
||||
def open_tag(name, tabulation, atomic, try_one_line, class_id, attributes_hash, obj_ref, flattened)
|
||||
|
|
|
@ -34,6 +34,9 @@ module Haml
|
|||
# Designates an XHTML doctype.
|
||||
DOCTYPE = '!'[0]
|
||||
|
||||
# Designates an XML processing instruction.
|
||||
PROCESS = '?'[0]
|
||||
|
||||
# Designates script, the result of which is output.
|
||||
SCRIPT = '='[0]
|
||||
|
||||
|
@ -57,6 +60,7 @@ module Haml
|
|||
DIV_ID,
|
||||
COMMENT,
|
||||
DOCTYPE,
|
||||
PROCESS,
|
||||
SCRIPT,
|
||||
FLAT_SCRIPT,
|
||||
SILENT_SCRIPT
|
||||
|
@ -210,6 +214,8 @@ module Haml
|
|||
render_tag(line, index)
|
||||
when COMMENT
|
||||
render_comment(line)
|
||||
when PROCESS
|
||||
render_process(line, index)
|
||||
when SCRIPT
|
||||
push_script(line[1..-1], false, index)
|
||||
when FLAT_SCRIPT
|
||||
|
@ -404,6 +410,17 @@ module Haml
|
|||
push_silent "_hamlout.close_comment(#{has_conditional}, #{@tabulation})"
|
||||
end
|
||||
|
||||
# Renders an XML processing direction.
|
||||
def render_process(line, index)
|
||||
target, attributes = line[1..-1].split("{")
|
||||
target = "xml" if target.empty?
|
||||
if attributes
|
||||
push_silent "_hamlout.push_proc(#{target.dump}, {#{attributes}, #{@tabulation})"
|
||||
else
|
||||
push_text "<?#{target} ?>"
|
||||
end
|
||||
end
|
||||
|
||||
# Parses a line that will render as an XHTML tag, and adds the code that will
|
||||
# render that tag to <tt>@precompiled</tt>.
|
||||
def render_tag(line, index)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?xml encoding='UTF-8' version='1.0' ?>
|
||||
<?xml-stylesheet href='/non/existant/stylesheet.css' type='text/css' ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
?{ :version => "1.0", :encoding => "UTF-8" }
|
||||
?xml-stylesheet{ :href => "/non/existant/stylesheet.css", :type => "text/css" }
|
||||
!!!
|
||||
!!! 1.1
|
||||
!!! 1.1 Strict
|
||||
|
|
Loading…
Reference in a new issue