javascriptwordpressgulpgulp-replace

Variable value in gulp replace


I am currently working on creating a script that converts a html website into a WordPress template.

I know that you can replace text and other values in files with text. But is there also a way to replace those with another variable's values?

I want to change the template name to the name the user sets before this``

.pipe(replace('TEMPLATENAME', '<%= pkg.name %>'))

and ofcourse the output I get now is:

register_nav_menus( array(
'primary' => __( 'Primary Menu', '<%= pkg.name %>' ),) );

Solution

  • If what you want is TEMPLATENAME to be replaced by the value in pkg.name you should do something like this:

    .pipe(replace('TEMPLATENAME', pkg.name))