Пример #1
0
def build_page(path):
	if not getattr(frappe.local, "path", None):
		frappe.local.path = path

	context = get_context(path)

	if context.source:
		html = frappe.render_template(context.source, context)

	elif context.template:
		if path.endswith('min.js'):
			html = frappe.get_jloader().get_source(frappe.get_jenv(), context.template)[0]
		else:
			html = frappe.get_template(context.template).render(context)

	if '{index}' in html:
		html = html.replace('{index}', get_toc(context.route))

	if '{next}' in html:
		html = html.replace('{next}', get_next_link(context.route))

	# html = frappe.get_template(context.base_template_path).render(context)

	if can_cache(context.no_cache):
		page_cache = frappe.cache().hget("website_page", path) or {}
		page_cache[frappe.local.lang] = html
		frappe.cache().hset("website_page", path, page_cache)

	return html
Пример #2
0
def build_page(path):
    if not getattr(frappe.local, "path", None):
        frappe.local.path = path

    context = get_context(path)

    if context.source:
        html = frappe.render_template(context.source, context)

    elif context.template:
        if path.endswith('min.js'):
            html = frappe.get_jloader().get_source(frappe.get_jenv(),
                                                   context.template)[0]
        else:
            html = frappe.get_template(context.template).render(context)

    if '{index}' in html:
        html = html.replace('{index}', get_toc(context.route))

    if '{next}' in html:
        html = html.replace('{next}', get_next_link(context.route))

    # html = frappe.get_template(context.base_template_path).render(context)

    if can_cache(context.no_cache):
        page_cache = frappe.cache().hget("website_page", path) or {}
        page_cache[frappe.local.lang] = html
        frappe.cache().hset("website_page", path, page_cache)

    return html
Пример #3
0
 def get_raw_template(self):
     return frappe.get_jloader().get_source(frappe.get_jenv(),
                                            self.context.template)[0]