Created
July 15, 2012 01:21
-
-
Save reaktivo/3114250 to your computer and use it in GitHub Desktop.
Expose jade templares
This file contains 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
app = require '../app' | |
require 'express-expose' | |
jade = require 'jade' | |
path = require 'path' | |
fs = require 'fs' | |
cache = {} | |
scriptWrap = (src) -> | |
"<script>#{src}</script>" | |
app.helpers | |
view: (viewName) -> | |
if process.env.NODE_ENV is not "production" or !cache[viewName] | |
filepath = path.join app.settings.views, viewName + ".jade" | |
console.log filepath | |
source = fs.readFileSync filepath | |
compiled = jade.compile source, | |
client: true | |
compileDebug: false | |
cache[viewName] = scriptWrap "app.templates['#{viewName}'] = #{compiled.toString()}" | |
cache[viewName] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment