wesleytodd / YeoPress

A Yeoman generator for WordPress
Other
1.08k stars 161 forks source link

Adding "theme name" tags to template? #128

Closed benjaminallison closed 9 years ago

benjaminallison commented 9 years ago

So when scaffolding with a theme, YeoPress, asks me what the theme directory should be. It would be really neat YeoPress could also populate specified tags within my theme.

Example, say my theme name is mysite. In my functions.php file, I have the following function:

<%themeName%>_init function() {
// code
}

Well, when YeoPress does it's thang, it could look for that tag <%themeName%>, turning that function into:

mysite_init function() {
// code
}

One great application is in the wp_register_script declaration for livereload:

wp_register_script('livereload', 'http://localhost/<%themeName%>:35729/livereload.js?snipver=1', null, false, true);

becomes

wp_register_script('livereload', 'http://localhost/mysite:35729/livereload.js?snipver=1', null, false, true);

Just an idea!

wesleytodd commented 9 years ago

I think there is the possibility that it might just work that way. I cannot find in the yeoman docs which methods get parsed for templates on a remote call, but it uses the normal built-in copy methods (directory and tarball), which I think process templates. Did you try it and it didn't work?

benjaminallison commented 9 years ago

Huh. I'm new to Yeoman and didn't even know anything like that was possible! Cool.

The idea was that a value I entered into YeoPress would be used to fill the template tag (say, when I'm asked what the theme directory is called). Is that value exposed in some way that a template tag could work with?

wesleytodd commented 9 years ago

I think that by default it will use the input which is attached to the generator instance. Take a look at the templates in app/tempaltes for examples. The values in the prompts are in the prompts.js file.

Let me know what you find.

benjaminallison commented 9 years ago

Awesome! Wherever I throw <%= conf.get('themeDir') %> in my Wordpress theme files, it's replaced with the value I entered for the custom theme directory name. So great!

wesleytodd commented 9 years ago

Great! So can we close this?

benjaminallison commented 9 years ago

Close it up!

Even though it's a Yeoman thang, might be worth adding a sentence or two to the docs...

Benjamin Allison Designer

On Jan 13, 2015, at 6:54 PM, Wes Todd notifications@github.com wrote:

Great! So can we close this?

— Reply to this email directly or view it on GitHub.