예제 #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:
        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
파일: render.py 프로젝트: kickapoo/frappe
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:
		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
파일: render.py 프로젝트: erpnext-tm/frappe
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
예제 #4
0
    def update_toc(self, html):
        if '{index}' in html:
            html = html.replace('{index}', get_toc(self.path))

        if '{next}' in html:
            html = html.replace('{next}', get_next_link(self.path))

        return html