예제 #1
0
    def test_input_dict__lookup_template_filename__with_namespace(self):
        from korpokkur.emitter.mako import (
            MakoEmitter, 
            InputEnv
        )

        input = self._makeDictInput({"name": "foo"})
        filename = os.path.join(self.HERE, "hello_with_helpers.mako")

        target = MakoEmitter(InputEnv)
        result = target.emit(input, filename=filename)
        self.assertEqual(result.strip(), "foo,foo")
예제 #2
0
    def test_input_commandline(self):
        from korpokkur.emitter.mako import (
            MakoEmitter,
            InputEnv
        )

        input = self._makeCommandLineInput(input_string="foo\n")
        template = "myname is ${name}"

        target = MakoEmitter(InputEnv)
        result = target.emit(input, text=template)
        self.assertEqual(result, "myname is foo")
예제 #3
0
    def test_it(self):
        from korpokkur.emitter.mako import (
            MakoEmitter, 
            InputEnv
        )

        input = self._makeDictInput({"name": "foo"})
        template = "myname is ${name}"

        target = MakoEmitter(InputEnv)
        result = target.emit(input, text=template)
        self.assertEqual(result, "myname is foo")
예제 #4
0
    def test_input_commandline__with_deftemplate(self):
        from korpokkur.emitter.mako import (
            MakoEmitter,
            InputEnv
        )

        input = self._makeCommandLineInput(input_string="foo\n")
        template = """\
<%def name="greeting(name)">
myname is ${name}
</%def>
${greeting(name)}
${greeting(name)}
"""

        target = MakoEmitter(InputEnv)
        result = target.emit(input, text=template).replace("\n", "")
        self.assertEqual(result, "myname is foomyname is foo")