Sha256: e4b3bf5d2ddb6d764cea003688c26c73eefb9e083adbf8464ae9831f7710ef41

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>process_attributes_if (Tailor)</title>
<link rel=StyleSheet href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body bgcolor="white">
<pre><span class="cmt"># File tailor.rb, line 182</span>
  <span class="kw">def</span> process_attributes_if(xml_context, eval_context)
    elements = REXML::XPath.match(xml_context, <span class="str">'.//*[@attributes_if]'</span>)
    elements.each <span class="kw">do</span> |element|
      <span class="kw">begin</span>
        assignments = element.attributes[<span class="str">'attributes_if'</span>].split(<span class="str">'\\'</span>)
        assignments.each <span class="kw">do</span> |assignment|
          attribute_name, attribute_condition = assignment.split(<span class="str">'='</span>)
          attribute_name.strip!
          attribute_condition.strip!
          result = eval(attribute_condition.untaint, eval_context)
          <span class="kw">if</span> <span class="kw">not</span> result
            <span class="kw">if</span> element.attributes.has_key?(attribute_name)
              element.attributes.get_attribute(attribute_name).remove
            <span class="kw">end</span>
          <span class="kw">end</span>
        <span class="kw">end</span>
        element.attributes.get_attribute(<span class="str">'attributes_if'</span>).remove
      <span class="kw">rescue</span> NameError
        <span class="kw">next</span>
      <span class="kw">end</span>
    <span class="kw">end</span>
  <span class="kw">end</span></pre>
</body>
</html>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mega-0.3.1 pub/xml/xmltailor/rdoc/classes/Tailor.src/M000009.html