本文整理汇总了Python中pyramid_jinja2.compat.text_函数的典型用法代码示例。如果您正苦于以下问题:Python text_函数的具体用法?Python text_怎么用?Python text_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_relative_tmpl_extends_relbase
def test_relative_tmpl_extends_relbase(self):
from pyramid.renderers import render
# this should pass as it will fallback to the new search path
# and find it from there
self.config.add_jinja2_search_path('pyramid_jinja2.tests:')
result = render('extends_relbase.jinja2', {'a': 1})
self.assertEqual(result, text_('\nHello fööYo!', 'utf-8'))
开发者ID:renierdbruyn,项目名称:pyramid_jinja2,代码行数:7,代码来源:test_it.py
示例2: test_directory
def test_directory(self):
from pyramid_jinja2 import includeme
config = testing.setUp()
config.registry.settings['jinja2.bytecode_caching_directory'] = '/foobar'
includeme(config)
env = config.get_jinja2_environment()
self.assertEqual(env.bytecode_cache.directory, text_('/foobar'))
开发者ID:0x1997,项目名称:pyramid_jinja2,代码行数:7,代码来源:test_it.py
示例3: test_recursive_tmpl
def test_recursive_tmpl(self):
from pyramid.renderers import render
self.config.add_jinja2_renderer('.html')
self.config.add_jinja2_search_path(
'pyramid_jinja2.tests:templates/recursive', name='.html')
result = render('admin/index.html', {})
self.assertEqual(result, text_('foo'))
开发者ID:EyeOfPython,项目名称:japanese,代码行数:7,代码来源:test_it.py
示例4: test_abs_tmpl_extends
def test_abs_tmpl_extends(self):
import os.path
from pyramid.renderers import render
here = os.path.abspath(os.path.dirname(__file__))
result = render(os.path.join(here, 'templates', 'extends.jinja2'),
{'a': 1})
self.assertEqual(result, text_('\nHello fööYo!', 'utf-8'))
开发者ID:EyeOfPython,项目名称:japanese,代码行数:7,代码来源:test_it.py
示例5: test_filter_and_test_works_in_render
def test_filter_and_test_works_in_render(self):
import pyramid_jinja2
from pyramid.renderers import render
config = testing.setUp()
config.add_settings({
'jinja2.directories': 'pyramid_jinja2.tests:templates',
'jinja2.tests': 'my_test = pyramid_jinja2.tests.test_it.my_test_func',
'jinja2.filters': 'my_filter = pyramid_jinja2.tests.test_it.my_test_func'
})
config.add_renderer('.jinja2', pyramid_jinja2.renderer_factory)
result = render('tests_and_filters.jinja2', {})
#my_test_func returs "True" - it will be render as True when usign
# as filter and will pass in tests
self.assertEqual(result, text_('True is not False', 'utf-8'))
testing.tearDown()
开发者ID:aMunRieL,项目名称:pyramid_jinja2,代码行数:15,代码来源:test_it.py
示例6: test_delay_init
def test_delay_init(self):
from pyramid_jinja2 import FileInfo
class MyFileInfo(FileInfo):
filename = 'foo.jinja2'
def __init__(self, data):
self.data = data
FileInfo.__init__(self, self.filename)
def open_if_exists(self, fname):
return StringIO(self.data)
def getmtime(self, fname):
return 1
mi = MyFileInfo(text_('nothing good here, move along'))
mi._delay_init()
self.assertEqual(mi._contents, mi.data)
开发者ID:Mbosco,项目名称:pyramid_jinja2,代码行数:19,代码来源:test_it.py
示例7: test_it
def test_it(self):
from pyramid.config import Configurator
from pyramid_jinja2 import includeme
from webtest import TestApp
import os
here = os.path.abspath(os.path.dirname(__file__))
templates_dir = os.path.join(here, 'templates')
def myview(request):
return {'what': 'eels'}
config = Configurator(settings={
'jinja2.directories': templates_dir,
'jinja2.newstyle': True})
includeme(config)
config.add_view(view=myview, renderer='newstyle.jinja2')
app = config.make_wsgi_app()
testapp = TestApp(app)
self.assertEqual(testapp.get('/').body.decode('utf-8'), text_('my hovercraft is full of eels!'))
开发者ID:Mbosco,项目名称:pyramid_jinja2,代码行数:21,代码来源:test_it.py
示例8: test_delay_init
def test_delay_init(self):
from pyramid_jinja2 import FileInfo, TemplateRenderingError
class MyFileInfo(FileInfo):
filename = 'foo.jinja2'
def __init__(self, data):
self.data = data
FileInfo.__init__(self, self.filename)
def open_if_exists(self, fname):
return StringIO(self.data)
def getmtime(self, fname):
return 1
mi = MyFileInfo(text_('nothing good here, move along'))
mi._delay_init()
self.assertEqual(mi._contents, mi.data)
if not PY3:
mi = MyFileInfo(bytes_('nothing good her\xe9, move along'))
self.assertRaises(TemplateRenderingError, mi._delay_init)
开发者ID:jpfarias,项目名称:pyramid_jinja2,代码行数:24,代码来源:test_it.py
示例9: test_render_relative_to_package
def test_render_relative_to_package(self):
from pyramid.renderers import render
result = render('templates/helloworld.jinja2', {'a': 1})
self.assertEqual(result, text_('\nHello föö', 'utf-8'))
开发者ID:Mbosco,项目名称:pyramid_jinja2,代码行数:4,代码来源:test_it.py
示例10: test_render
def test_render(self):
from pyramid.renderers import render
result = render('helloworld.jinja2', {'a': 1})
self.assertEqual(result, text_('\nHello föö', 'utf-8'))
开发者ID:Mbosco,项目名称:pyramid_jinja2,代码行数:4,代码来源:test_it.py
示例11: test_tmpl_extends_abs
def test_tmpl_extends_abs(self):
from pyramid.renderers import render
result = render('extends_abs.jinja2', {'a': 1})
self.assertEqual(result, text_('\nHello fööYo!', 'utf-8'))
开发者ID:renierdbruyn,项目名称:pyramid_jinja2,代码行数:4,代码来源:test_it.py
示例12: test_asset_tmpl_extends
def test_asset_tmpl_extends(self):
from pyramid.renderers import render
result = render('pyramid_jinja2.tests:templates/extends.jinja2',
{'a': 1})
self.assertEqual(result, text_('\nHello fööYo!', 'utf-8'))
开发者ID:renierdbruyn,项目名称:pyramid_jinja2,代码行数:5,代码来源:test_it.py
示例13: test_relative_tmpl_extends
def test_relative_tmpl_extends(self):
from pyramid.renderers import render
result = render('templates/extends.jinja2', {})
self.assertEqual(result, text_('\nHello fööYo!', 'utf-8'))
开发者ID:renierdbruyn,项目名称:pyramid_jinja2,代码行数:4,代码来源:test_it.py
示例14: test_asset_tmpl_deep_leaf
def test_asset_tmpl_deep_leaf(self):
from pyramid.renderers import render
result = render('pyramid_jinja2.tests:templates/deep/leaf.jinja2', {})
self.assertEqual(
result,
text_('sub-nav\n\ndeep-formsdeep-base deep-leaf', 'utf-8'))
开发者ID:EyeOfPython,项目名称:japanese,代码行数:6,代码来源:test_it.py
示例15: render
def render(self, values):
self.values = values
return text_('result')
开发者ID:0x1997,项目名称:pyramid_jinja2,代码行数:3,代码来源:base.py
注:本文中的pyramid_jinja2.compat.text_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论