Esempio n. 1
0
    def test_compile_new(self):
        from ptah import mustache

        f = os.path.join(self.path, 'template')
        with open(f, 'w') as fn:
            fn.write('<div>{{test}}</div>')

        tmpl = text_type(mustache.compile_template(f, mustache.NODE_PATH))

        self.assertTrue(os.path.isfile('%s.js'%f))
        self.assertIn(
            'function (Handlebars,depth0,helpers,partials,data) {', tmpl)
Esempio n. 2
0
    def test_compile_existing(self):
        from ptah import mustache

        f = os.path.join(self.path, 'template')
        with open(f, 'w') as fn:
            fn.write('<div>{{test}}</div>')

        time.sleep(0.01)

        f1 = '%s.js'%f
        with open(f1, 'w') as fn:
            fn.write('existing')

        tmpl = text_(mustache.compile_template(f, mustache.NODE_PATH))
        self.assertEqual('existing', tmpl)