Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(3)  |  Derive(0)  |  Import(3)

        def load_jinja():
    #: prepare loaders
    #: loaders = ['_templates', theme]
    loaders = []
    tpl = os.path.abspath('_templates')
    if os.path.exists(tpl):
        loaders.append(tpl)

    theme = find_theme()

    #: global variable
    g.theme_directory = theme

    theme_template = os.path.join(theme, 'templates')
    if os.path.exists(theme_template):
        loaders.append(theme_template)

    #: load default theme template always
    default_template = os.path.join(
        g.liquid_directory, '_themes/default/templates'
    )
    if default_template != theme_template:
        loaders.append(default_template)

    #: init jinja
    jinja = Environment(
        loader=FileSystemLoader(loaders),
        autoescape=False,  # blog don't need autoescape
        extensions=settings.writer.get('extensions') or [],
    )
    #: initialize globals
    jinja.globals = {}

    #: load template variables
    jinja.globals.update({
        'site': settings.site,
        'template': settings.template.get("vars") or {},
    })

    #: load theme variables
    config = {}
    theme_config = os.path.join(theme, 'settings.py')
    if os.path.exists(theme_config):
        logging.warn('settings.py in theme is deprecated since 3.4')
        logging.warn('the name should be changed to theme.py')
        execfile(theme_config, {}, config)
    theme_config = os.path.join(theme, 'theme.py')
    if os.path.exists(theme_config):
        execfile(theme_config, {}, config)

    #: user can reset theme variables
    config.update(settings.theme.get('vars') or {})
    #: keep namespace to the latest variables
    settings.theme['vars'] = config
    jinja.globals.update({'theme': config})

    #: default variables
    now = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
    jinja.globals.update({
        'system': {
            'name': 'Felix Felicis',
            'version': liquidluck.__version__,
            'homepage': liquidluck.__homepage__,
            'time': now,
        }
    })

    #: function helpers
    jinja.globals.update({
        'content_url': content_url,
        'static_url': static_url(os.path.join(theme, 'static')),
    })

    #: load theme filters
    config = {}
    theme_config = os.path.join(theme, 'filters.py')
    if os.path.exists(theme_config):
        execfile(theme_config, {}, config)

    jinja.filters.update(config)

    #: load filters from settings
    filters = settings.template.get("filters") or {}
    for k, v in filters.items():
        jinja.filters.update({k: import_object(v)})

    #: default filters
    jinja.filters.update({
        'xmldatetime': xmldatetime,
        'feed_updated': feed_updated,
        'permalink': permalink,
        'tag_url': tag_url,
        'year_url': year_url,
        'wiki_link': wiki_link,
    })

    #: load resource
    g.resource['posts'] = g.public_posts
    g.resource['pages'] = g.pure_pages
    jinja.globals.update({
        'resource': g.resource,
    })

    g.jinja = jinja
    return jinja
        


src/l/i/liquidluck-HEAD/liquidluck/generator.py   liquidluck(Download)
from liquidluck.options import g, settings
from liquidluck.utils import import_object, walk_dir, parse_settings
from liquidluck.writers.base import load_jinja, find_theme
 
 
        writers.append(import_object(name)())
 
    load_jinja()
 
    for writer in writers:

src/l/i/liquidluck-3.8.1/liquidluck/generator.py   liquidluck(Download)
from liquidluck.options import g, settings
from liquidluck.utils import import_object, walk_dir, parse_settings
from liquidluck.writers.base import load_jinja, find_theme
 
 
        writers.append(import_object(name)())
 
    load_jinja()
 
    for writer in writers:

src/l/i/liquidluck-HEAD/tests/test_writers_base.py   liquidluck(Download)
from liquidluck.writers.base import Pagination
from liquidluck.writers.base import get_post_slug
from liquidluck.writers.base import load_jinja
from liquidluck.options import settings
 
def test_load_jinja():
    load_jinja()