当前位置: 首页>>代码示例>>Python>>正文


Python Domain.get_template方法代码示例

本文整理汇总了Python中evoque.domain.Domain.get_template方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.get_template方法的具体用法?Python Domain.get_template怎么用?Python Domain.get_template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在evoque.domain.Domain的用法示例。


在下文中一共展示了Domain.get_template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_evoque_local_nested_from_string

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_evoque_local_nested_from_string(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     src = open(join(DEFAULT_DIR, "evoque_local_nested.html")).read()
     name = "fromstr"
     nested_name = name + "#label"
     data = dict(title="A Title", param="A Param")
     r = "<h1>A Title</h1><p>some A Param text</p>"
     # Load a from_string template that locally-nests another template
     td.set_template(name, src=src, from_string=True)
     t1 = td.get_template(name)
     # Verify nested template is not yet loaded
     self.assertEqual(False, t1.collection.has_template(nested_name))
     # Evoque, and verify response (multiple times, ensure data stays ok)
     self.assertEqual(r, t1.evoque(data)) # data as locals
     self.assertEqual(r, t1.evoque(**data)) # data as kw
     self.assertEqual(r, t1.evoque(data)) # data as locals
     self.assertEqual(r, t1.evoque(**data)) # data as kw
     # Verify nested template is now loaded
     self.assertEqual(True, t1.collection.has_template(nested_name))
     # Verify that tring to set nested template will fail
     self.assertRaises((ValueError,), td.set_template, nested_name, 
             src=src, from_string=True)
     t2 = td.get_template(nested_name)
     self.assertEqual(t2.ts, "<h1>%(title)s</h1><p>some %(param)s text</p>")
     self.assertEqual(r, t2.evoque(**data))
开发者ID:DamnWidget,项目名称:goliat,代码行数:27,代码来源:test_evoque.py

示例2: test_overlay

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_overlay(self):
     td = Domain(DEFAULT_DIR)
     t = td.get_template('overlay.html')
     self.assertEqual(
             eval("dict(%s)"%(t.eval_overlay)), dict(name="base.html"))
     space, overlay = t.get_space_overlay()
     self.failUnless(space is True)
     self.failUnless(t.labels == ["content"])
     # t.evoque(title="positive overlay test", parametrized="and happy")
     
     chain_pos = td.get_template('overlay_chain_pos.html')
     self.assertEqual(
         eval("dict(%s)"%(chain_pos.eval_overlay)), dict(name="overlay_mid.html"))
     space, overlay = chain_pos.get_space_overlay()
     self.failUnless(space is True)
     self.failUnless(chain_pos.labels == ["content"])
     # chain_pos.evoque(title="positive overlay test", parametrized="and happy")
     
     chain_neg = td.get_template('overlay_chain_neg.html')
     self.assertEqual(eval("dict(%s)"%(chain_neg.eval_overlay)), 
         dict(name="overlay_mid.html", space="negative"))
     space, overlay = chain_neg.get_space_overlay()
     self.failUnless(space is False)
     self.failUnless(chain_neg.labels == ["content", "footer"])
     # chain_neg.evoque(title="negative overlay test", parametrized="and happy")
     
     b = td.get_template('base.html')
     self.failUnless(b.labels == ["header", "content", "footer"])
     self.failIf(b.eval_overlay is not None)
     self.assertRaises((TypeError,), b.get_space_overlay)
开发者ID:DamnWidget,项目名称:goliat,代码行数:32,代码来源:test_overlay.py

示例3: test_raw_nested

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
    def test_raw_nested(self):
        if not xml:
            return 
        td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
        t = td.get_template('raw_nested.html')
        self.assertEqual(t.evoque()[:87], """
$begin{table_row}
    $for{ col in row }
        &lt;td&gt;${col}&lt;/td&gt;
    $else""")
        self.failUnless(isinstance(t.evoque(), xml))
        # template #snapshot is already loaded with raw=True, quoting=str
        snap = td.get_template('raw_nested.html#snapshot')
        self.failUnless(snap.raw)
        self.failUnless(snap.qsclass is unistr)
        self.failUnless(isinstance(snap.evoque(), unistr))
        # template #snapshot is still already loaded...
        snapx = td.get_template('raw_nested.html#snapshot_xml')
        self.failUnless(isinstance(snapx.evoque(), xml))
        self.failUnless(snap.qsclass is unistr)
        self.failUnless(isinstance(snap.evoque(), unistr))
        snap.unload()
        self.failUnless(isinstance(snapx.evoque(), xml)) # reloads #snapshot
        snap = td.get_template('raw_nested.html#snapshot')
        self.failUnless(snap.qsclass is xml)
        self.failUnless(isinstance(snap.evoque(raw=True), xml))
开发者ID:DamnWidget,项目名称:goliat,代码行数:28,代码来源:test_evoque.py

示例4: test_expr_formatting

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_expr_formatting(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     data = dict(amount=1.0/3)
     src = "${amount!.4f}"
     td.set_template("t1", src=src, from_string=True)
     self.assertEqual("0.3333", td.get_template("t1").evoque(**data))
     src = "${ amount ! .3f }"
     td.set_template("t2", src=src, from_string=True)
     self.assertEqual("0.333", td.get_template("t2").evoque(**data))
开发者ID:DamnWidget,项目名称:goliat,代码行数:11,代码来源:test_evoque.py

示例5: test_prefer

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_prefer(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     t = td.get_template('raw_nested.html')
     self.assertEqual(t.prefer, dict(raw=False, quoting="xml"))
     def upper(s): 
         return s.upper()
     td.set_on_globals("upper", upper)
     p = td.get_template('raw_nested.html#preferences')
     self.assertEqual(p.raw, True)
     self.assertEqual(p.qsclass, unistr)
开发者ID:DamnWidget,项目名称:goliat,代码行数:12,代码来源:test_evoque.py

示例6: test_evoque_local_nested

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_evoque_local_nested(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     name = 'evoque_local_nested.html'
     data = dict(title="A Title", param="A Param")
     r = "<h1>A Title</h1><p>some A Param text</p>"
     # Load a nested template and evoque it
     t1 = td.get_template(name + "#label")
     self.assertEqual(t1.ts, "<h1>%(title)s</h1><p>some %(param)s text</p>")
     self.assertEqual(r, t1.evoque(**data))
     # Load a template that evoques a locally-nested template
     t2 = td.get_template(name)
     self.assertEqual(r, t2.evoque(**data))
开发者ID:DamnWidget,项目名称:goliat,代码行数:14,代码来源:test_evoque.py

示例7: test_overlay_naming_schemes_separate_files

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_overlay_naming_schemes_separate_files(self):
     domain = Domain(DEFAULT_DIR)
     t0 = domain.get_template("overlay_naming_base.html")
     self.assertEqual(t0.evoque(), "<base>base content!</base>")
     t1 = domain.get_template("overlay_naming_1.html")
     self.assertEqual(t1.evoque(), "<base><m1>literal unquoted</m1></base>")
     t2 = domain.get_template("overlay_naming_2.html")
     self.assertEqual(t2.evoque(), "<base><m2>literal quoted</m2></base>")
     t3 = domain.get_template("overlay_naming_3.html")
     self.assertEqual(t3.evoque(site_template="overlay_naming_base.html"), 
         "<base><m3>kw unquoted</m3></base>")
     t4 = domain.get_template("overlay_naming_4.html")
     self.assertEqual(t4.evoque(), "<base><m4>kw quoted</m4></base>")
开发者ID:DamnWidget,项目名称:goliat,代码行数:15,代码来源:test_overlay.py

示例8: write_rnaseq_script

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
def write_rnaseq_script(globals,pipeline,sample):
    domain=globals['domain']
    d=Domain(domain)
    t=d.get_template(globals['rnaseq_template'])

    # build up list of rnaseq.steps to be included in the final script:

    # augment globals hash with rnaseq vars:
    vars={'globals_file':'globals.yml',
          'rnaseq_steps':pipeline.as_python(),
          'steps_syml':os.path.join(globals['python_lib'],'pipeline.steps.syml'),     # hardcoded (for now?)
          'sample_yml':sample.conf_file,
          'timestamp':sample.timestamp(),
          }
    vars.update(globals)
    rnaseq_script=t.evoque(vars)

    # write script:
    os.mkdir(os.path.join(sample.working_dir(),'starflow','rnaseq'))
    fn=pipeline.script_filename('starflow/rnaseq','rnaseq','py')
    f=open(fn, 'w')
    f.write(rnaseq_script)
    f.close
    print "%s written" % fn
    return fn
开发者ID:icefoxx,项目名称:rna-seq-scripts,代码行数:27,代码来源:pipeline0.py

示例9: test_get_mixed_name_src

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_get_mixed_name_src(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     name = '#label'
     src = 'evoque_local_nested.html'
     # Load a nested template and evoque it
     t = td.get_template(name, src)
     self.assertEqual(t.ts, "<h1>%(title)s</h1><p>some %(param)s text</p>")
开发者ID:DamnWidget,项目名称:goliat,代码行数:9,代码来源:test_evoque.py

示例10: test_literals

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_literals(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     name = "template.html"
     t = td.get_template(name + "#literals")
     r = "<p>a $ dollar, a literal ${expr}, a % percent... { } ! \ etc.</p>"
     self.assertEqual(r, t.evoque())
     self.assertRaises((SyntaxError,), td.get_template, name+"#unescaped")
开发者ID:DamnWidget,项目名称:goliat,代码行数:9,代码来源:test_evoque.py

示例11: test_from_string_td

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_from_string_td(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     src = "<h1>${title}</h1><p>some ${param} text</p>"
     data = dict(title="A Title", param="A Param")
     r = "<h1>A Title</h1><p>some A Param text</p>"
     td.set_template("fromstr", src=src, from_string=True)
     t = td.get_template("fromstr")
     self.assertEqual(r, t.evoque(**data))
开发者ID:DamnWidget,项目名称:goliat,代码行数:10,代码来源:test_evoque.py

示例12: test_overlay_kwargs

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_overlay_kwargs(self):
     td = Domain(DEFAULT_DIR)
     r = "<base>base content!</base>"
     r_neg = ""
     responses = [ r, r, r, r, r_neg ]
     t = td.get_template('overlay_kwargs.html')
     for i, s in enumerate(t.test()):
         self.assertEqual(responses[i], s)
开发者ID:DamnWidget,项目名称:goliat,代码行数:10,代码来源:test_overlay.py

示例13: test_evoque_raw

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_evoque_raw(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS)
     name = 'evoque_local_nested.html#label'
     r = "<h1>${title}</h1><p>some ${param} text</p>"
     t = td.get_template(name, raw=True)
     self.assertEqual([], list(t.test()))
     self.assertEqual(None, t.ts)
     self.assertEqual(r, t.evoque(raw=True))
     self.assertEqual(r, t.evoque())
开发者ID:DamnWidget,项目名称:goliat,代码行数:11,代码来源:test_evoque.py

示例14: test_evoque_kwargs

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_evoque_kwargs(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=4)
     r = "<h1>TITLE</h1><p>some PARAM text</p>"
     r_raw = "<h1>${title}</h1><p>some ${param} text</p>"
     r_q_str = "&lt;h1&gt;TITLE&lt;/h1&gt;&lt;p&gt;some PARAM text&lt;/p&gt;"
     responses = [ r, r, r, r, r, r_raw, r, r_q_str, r ]
     t = td.get_template('evoque_kwargs.html')
     for i, s in enumerate(t.test()):
         self.assertEqual(responses[i], s)
开发者ID:DamnWidget,项目名称:goliat,代码行数:11,代码来源:test_evoque.py

示例15: test_manual_quoting

# 需要导入模块: from evoque.domain import Domain [as 别名]
# 或者: from evoque.domain.Domain import get_template [as 别名]
 def test_manual_quoting(self):
     td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS, quoting="str")
     name = "template.html#label"
     t = td.get_template(name)
     self.failUnless(unistr is t.qsclass)
     self.failUnless(unistr is t.evoque(title="str", param="<str/>").__class__)
     from cgi import escape
     self.assertEqual(self.r_xml_escaped, 
             t.evoque(title="q-xml", param=escape("<in>rm *</in>")))
开发者ID:DamnWidget,项目名称:goliat,代码行数:11,代码来源:test_evoque.py


注:本文中的evoque.domain.Domain.get_template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。