コード例 #1
0
ファイル: base.py プロジェクト: ksava/PyHAML
 def assertMako(self, source, expected, *args):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node).replace('<%! from haml import runtime as __HAML %>\\\n', '')
     self.assertEqual(
         mako.replace('    ', '\t'),
         expected.replace('    ', '\t'),
         *args
     )
コード例 #2
0
ファイル: base.py プロジェクト: ksava/PyHAML
 def assertHTML(self, source, expected, *args, **kwargs):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node)
     html = Template(mako).render_unicode(**kwargs)
     self.assertEqual(
         html.replace('    ', '\t'),
         expected.replace('    ', '\t'),
         *args
     )
コード例 #3
0
ファイル: __init__.py プロジェクト: lagra/PyHAML
 def assertMako(self, source, expected, *args):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node).replace('<%! from haml.codegen import mako_build_attr_str as __P_attrs %>\\\n', '')
     self.assertEqual(mako, expected.replace('    ', '\t'), *args)
コード例 #4
0
ファイル: main.py プロジェクト: lagra/PyHAML
        %p
            The content goes in here.
            This is another line of the content.
        %p.warning
            This is a warning.
        -
            range(10)

'''


print '===== SOURCE ====='
print source.strip()
print

root = haml.parse_string(source)



print '===== NODES ====='
root.print_tree()
print

print '===== MAKO ====='
compiled = haml.generate_mako(root)
print compiled.strip()
print

# print '===== COMPILED MAKO ====='
template = Template(compiled)
# print template._code.strip()
コード例 #5
0
ファイル: main.py プロジェクト: akubera/PyHAML
:less
    body {
        margin: 0;
    }
    p {
        color: #fff;
    }

'''

print('===== SOURCE =====')
print(source.strip())
print()

root = haml.parse_string(source)

print('===== NODES =====')
root.print_tree()
print()

print('===== MAKO =====')
compiled = haml.generate_mako(root)
print(compiled.strip())
print()

template = Template(compiled)
if True:
    print('===== COMPILED MAKO =====')
    print(template._code.strip())
    print()
コード例 #6
0
 def assertHTML(self, source, expected, *args, **kwargs):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node)
     html = Template(mako).render_unicode(**kwargs)
     self.assertEqual(html.replace('    ', '\t'),
                      expected.replace('    ', '\t'), *args)
コード例 #7
0
 def assertMako(self, source, expected, *args):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node).replace(
         '<%! from haml import runtime as __HAML %>\\\n', '')
     self.assertEqual(mako.replace('    ', '\t'),
                      expected.replace('    ', '\t'), *args)
コード例 #8
0
ファイル: readme_tut.py プロジェクト: startling/PyHAML
import haml
import mako.template

# 1. Write your HAML.
haml_source = '.content Hello, World!'

# 2. Parse your HAML source into a node tree.
haml_nodes = haml.parse_string(haml_source)

# 3. Generate Mako template source from the node tree.
mako_source = haml.generate_mako(haml_nodes)

# 4. Render the template.
print mako.template.Template(mako_source).render_unicode()
コード例 #9
0
ファイル: __init__.py プロジェクト: startling/PyHAML
 def assertMako(self, source, expected, *args):
     node = haml.parse_string(source)
     mako = haml.generate_mako(node).replace(
         '<%! from haml.codegen import mako_build_attr_str as __P_attrs %>\\\n',
         '')
     self.assertEqual(mako, expected.replace('    ', '\t'), *args)