Browse files

working plugin - compiles source and supports the options

  • Loading branch information...
1 parent 9bd22c3 commit f1e4f0252ec621d2c4ef4caf4ab00006f2373a7f @emirotin committed Oct 5, 2012
Showing with 13 additions and 4 deletions.
  1. +2 −1 .gitignore
  2. +11 −3 src/cjade.plugin.coffee
View
3 .gitignore
@@ -1 +1,2 @@
-.idea
+.idea
+out
View
14 src/cjade.plugin.coffee
@@ -25,11 +25,19 @@ module.exports = (BasePlugin) ->
if inExtension == 'cjade' and outExtension in ['js',null]
jade = require 'jade'
- console.log file
# Fetch useful paths
- fullDirPath = file.get('fullDirPath')
+ key = file.get('relativeOutPath')
+ if config.stripJsExt and key[-3..] == '.js'
+ key = key[..-4]
+ if config.baseDir and config.baseDir.length and key[...config.baseDir.length] == config.baseDir
+ key = key[config.baseDir.length+1..]
+ preamble = """
+ #{config.namespace} = #{config.namespace} || {};
+ #{config.namespace}['#{key}'] = function
+ """
+ compiled = '' + jade.compile(opts.content, client: true, filename: file.get('url'), pretty: config.prettify, debug: !config.prettify)
- opts.content = '123'
+ opts.content = compiled.replace 'function anonymous', preamble
next()

0 comments on commit f1e4f02

Please sign in to comment.