Skip to content

Commit

Permalink
working plugin - compiles source and supports the options
Browse files Browse the repository at this point in the history
  • Loading branch information
emirotin committed Oct 4, 2012
1 parent 9bd22c3 commit f1e4f02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
out
14 changes: 11 additions & 3 deletions src/cjade.plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.