Created
October 26, 2011 01:38
-
-
Save narqo/1315148 to your computer and use it in GitHub Desktop.
Simple BEMHTML renderer via PyV8 (code.google.com/p/pyv8/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Dead simple BEMHTML renderer concept via PyV8 (code.google.com/p/pyv8/) | |
import os | |
import PyV8 | |
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
PAGE = os.path.join(PROJECT_ROOT, 'pages/page') | |
ctxt = PyV8.JSContext() | |
ctxt.enter() | |
bemjson = open(os.path.join(PAGE, 'example.bemjson.js')) | |
bemhtml = open(os.path.join(PAGE, 'example.bemhtml.js')) | |
# Evaluting bemhtml.js template | |
ctxt.eval(bemhtml.read()) | |
# `json.dumps`? | |
html = ctxt.eval("BEMHTML.apply(" + bemjson.read() + ")") | |
print html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment