Sha256: 99d619d5919fbcb75e5ea7d03a708b878b325b9a050a72b3a06a41139f1f28e3

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

require 'test/unit'

require 'nitro/compiler/elements'

include Nitro

$source = %{
<html>
  <?r a = 5 ?>
  Here is some text
  <body style="hidden" name="1">
    Some more
    <Box color="#f00">
      Hello World
      <Box color="#ff0">
        <b>nice</b>
        <i>stuff</i>
        <Box color="#fff">
          It works
        </Box>
      </Box>
      Text
    </Box>
    The End
  </body>
</html>
}

$source2 = %{
  <x:box color="#ff0">
    xhtml mode
  </x:box>  
}

$source3 = %{
  <Page>
    <Box>Hello</Box>
    <Box>World</Box>
    <Bar>Foo</Bar>
  </Page>
}

class Page < Nitro::Element
  def render
    %~
    <html id="2">
      #{content}
      #{content :foo}
    </html>
    ~
  end
end

class Box < Nitro::Element
  def open
    %|<div style="color: #@color">|
  end
  
  def close
    "</div>"
  end
end

class Bar < Nitro::Element
  name :foo
  
  def render
    %~
    This is a great #{content}.
    ~
  end
end

class TC_Element < Test::Unit::TestCase # :nodoc: all
  def test_all
    res = ElementProcessor.transform($source)
    assert_match /div style/, res
    res = ElementProcessor.transform($source2)
    assert_match /div style/, res
    res = ElementProcessor.transform($source3)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.26.0 test/nitro/tc_element.rb