Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setting to set current working directory to control paths #37

Closed
gibbitz opened this issue Dec 8, 2013 · 3 comments
Closed

add setting to set current working directory to control paths #37

gibbitz opened this issue Dec 8, 2013 · 3 comments

Comments

@gibbitz
Copy link

gibbitz commented Dec 8, 2013

I'd like to have a setting like grunt-contrib-copy's "cwd" argument that would allow me to output paths that reflect the actual path to the template html/haml files relative to a child folder where the templates are served. Let me explain:

As a non-fan of junk-drawer file organization, I've been building my Grunt projects with a "src" directory where my working editable files live and a "bin" folder where the processed output files (including the output template.js file) live. I keep my Gruntfile, package.json and readme in the root alongside of these project directories. In my "src" directory, I like for the files to work dynamically pulling the templates from the HTML and processing them with underscore in the browser. I have a switch that looks for the JST object and ignores the dynamic code in the bin directory.

The issue I have is that my JST paths contain 'src/' which is outside of root when serving from within the "src" or the "bin" directory. The workaround is to just use the output template.js file from the "src" directory, but I don't like the path having this artifact of the process, and it makes the src directory have a dependency on Grunt which as a matter of form, I was trying to avoid.

@tkellen
Copy link
Member

tkellen commented Dec 9, 2013

Good news--you can do this already, cwd / expand is not limited to the copy task.

Please see http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically.

@gibbitz
Copy link
Author

gibbitz commented Dec 9, 2013

Geez. I'm a fool. Not only did I not know this, but there's an identical ticket at the top of the closed issues with an almost identical response. Thanks for bothering to respond a second time.

@gibbitz gibbitz closed this as completed Dec 9, 2013
@gibbitz
Copy link
Author

gibbitz commented Dec 11, 2013

just a follow up. This didn't do what I expected from the grunt-contrib-copy standpoint in changing the paths fed to the task. the cwd was just appended when passed in. Not sure what voodoo was involved there, but I ended up resolving my issue by temporarily copying my HTML templates to root, running JST on them to produce the templates.js file with the root path, then removing the copied templates folder in my final cleanup. Less elegant, but it gets the same job done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants