wp-cli / scaffold-command

Generates code for post types, taxonomies, blocks, plugins, child themes, etc.
MIT License
165 stars 87 forks source link

Block scaffold command produces a syntax error when used with `--theme` argument #175

Closed kshaner closed 6 years ago

kshaner commented 6 years ago

Using the command wp scaffold block header --title="Header" --category=layout --theme produces a file with a syntax error on line 25 of the resulting block file:

    wp_register_script(
        'header-block-editor',
        get_template_directory_uri() . "/blocks/$index_js,
        array(
            'wp-blocks',
            'wp-i18n',
            'wp-element',
        ),
        filemtime( "$dir/$index_js" )
    );
schlessera commented 6 years ago

@kshaner I cannot replicate this right now. What is the exact syntax error you're getting? What theme are you adding this to? What versions of WP-CLI, WordPress and your theme are you using?

kshaner commented 6 years ago

Sorry @schlessera ,

WP_CLI: 2.0.1 Theme: Any I've tested (my custom theme, twentyseventeen) - the way it's built looks like it won't matter what theme is used.

The issue is that there is a missing quote mark in the mustache template for the theme at the end of line 34:

https://github.com/wp-cli/scaffold-command/blob/b5312a23edb121209cf201d16bb2896777f4f89f/templates/block-php.mustache#L34

If you include the block in functions.php you'll get a parse error.

schlessera commented 6 years ago

Ah, yes, I failed to actually include the block. I can confirm now.