Fixes for variable scope and wildcard issues in Hulk #106

Merged
merged 1 commit into from Aug 31, 2012

3 participants

@kruegerb

Summary of Issues fixed in this Pull Request

Variable scope issues (console)

The templates variable in the Hulk console output is never declared before attempting to initialize it, resulting in Uncaught ReferenceErrors. This is currently causing the Hulk tests to fail when attempting to eval(stdout) and errors to occur in the browser when importing the template as a script.

Variable scope issues (outputdir)

When passing the --outputdir flag to Hulk, individual .js templates are generated for each file, but these individual templates cannot be imported/loaded as they are missing a templates variable declaration. The output only includes the compiled template with its wrapper:

templates["test"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<p>");t.b(t.v(t.f("test",c,p,0)));t.b("</p>");return t.fl(); },partials: {}, subs: {  }});

Without the variable declaration, there isn't much of a point in generating the individual .js templates, as they cannot be imported as-is. It could be argued they are not meant to be imported individually, but rather concatenated and wrapped by an additional process, but in that case it makes more sense to pipe the console output to a file.

Wildcard with sub-directories issue

If a wildcard is passed to Hulk for a directory which contains sub-directories, Hulk will attempt to process those sub-directories as files with fs.readFileSync(sub-directory, 'utf-8'). Since a directory cannot be read as a file, this results in an illegal operation on a directory error.

Miscellaneous

Added line-breaks where necessary to standardize on two line-breaks before comments.

@travisbot

This pull request passes (merged 26a4f05 into c421bca).

@sayrer sayrer merged commit 9c6b4f6 into twitter:master Aug 31, 2012
@sayrer

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment