Closed monzou closed 11 years ago
Thanks @monzou! Just wondering specifically what the issue you're addressing is? It looks like it indents included code in CoffeeScript files - I'm guessing because whitespace matters in CoffeeScript and if you indented within the included file it might not be the correct indentation for the file that did the including?
@alanshaw
Sorry my test file was not correct and I fixed it.
BTW, My purpose is to include another CoffeeScript file with correct indent. I want to include CoffeeScript file that is not indented like following:
# module.coffee
class Module
constructor: (@name) ->
This is a normal valid CoffeScript file that defines single class. But I also want to include this file by another file like following:
define [], ->
# I want to include Module class here !
@@include('module.coffe')
But this makes incorrect CoffeeScript file.
# result
define [], ->
class Module
constructor: (@name) -> # invalid
in the test case, processIncludeContents
resolves this problem by following:
define [], ->
@@include('module.coffee', {"indent": "2"})
That makes correct CoffeeScript.
define [], ->
class Module
constructor: (@name) -> # valid
Ah I see, I was confused by the name I thought it was specifically for indenting coffeescript but I now see you could perform other transformations should you want to.
Do you think there are any other use cases? I'm just curious as to why you've solved the problem this way - I probably would have added an option for the task to auto indent file contents based on how indented the @@include
declaration was...
Released as 0.2.0 on NPM
Thanks !
Hmm ... I didn't know which is better for adding new option like smart indent
or process included contents
.
Then I selected the latter because It's seems more generic. But I don't know any other use cases for now.
Hi, @alanshaw
I added new option
processIncludeContents(contents, localVars)
to your task. If you don'd mind, can you merge this ?