本文整理汇总了Python中fanstatic.NeededResources.set_base_url方法的典型用法代码示例。如果您正苦于以下问题:Python NeededResources.set_base_url方法的具体用法?Python NeededResources.set_base_url怎么用?Python NeededResources.set_base_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fanstatic.NeededResources
的用法示例。
在下文中一共展示了NeededResources.set_base_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rendering_base_url
# 需要导入模块: from fanstatic import NeededResources [as 别名]
# 或者: from fanstatic.NeededResources import set_base_url [as 别名]
def test_rendering_base_url():
foo = Library('foo', '')
x1 = Resource(foo, 'a.js')
x2 = Resource(foo, 'b.css')
y1 = Resource(foo, 'c.js', depends=[x1, x2])
needed = NeededResources()
needed.need(y1)
assert needed.render() == '''\
<link rel="stylesheet" type="text/css" href="/fanstatic/foo/b.css" />
<script type="text/javascript" src="/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="/fanstatic/foo/c.js"></script>'''
needed = NeededResources(base_url='http://localhost/static')
needed.need(y1)
assert needed.render() == '''\
<link rel="stylesheet" type="text/css" href="http://localhost/static/fanstatic/foo/b.css" />
<script type="text/javascript" src="http://localhost/static/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="http://localhost/static/fanstatic/foo/c.js"></script>'''
# The base_url has been set.
assert needed.has_base_url()
needed.set_base_url('foo')
# The base_url can only be set once.
assert needed._base_url == 'http://localhost/static'
示例2: test_rendering_base_url_assign
# 需要导入模块: from fanstatic import NeededResources [as 别名]
# 或者: from fanstatic.NeededResources import set_base_url [as 别名]
def test_rendering_base_url_assign():
foo = Library('foo', '')
x1 = Resource(foo, 'a.js')
x2 = Resource(foo, 'b.css')
y1 = Resource(foo, 'c.js', depends=[x1, x2])
needed = NeededResources()
needed.need(y1)
needed.set_base_url('http://localhost/static')
assert needed.render() == '''\
示例3: test_rendering_base_url_assign
# 需要导入模块: from fanstatic import NeededResources [as 别名]
# 或者: from fanstatic.NeededResources import set_base_url [as 别名]
def test_rendering_base_url_assign():
foo = Library('foo', '')
x1 = Resource(foo, 'a.js')
x2 = Resource(foo, 'b.css')
y1 = Resource(foo, 'c.js', depends=[x1, x2])
needed = NeededResources(resources=[y1])
needed.set_base_url('http://localhost/static')
incl = Inclusion(needed)
assert incl.render() == '''\