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 Twig syntax check to Git pre-commit hook #44

Closed
TravisCarden opened this issue May 11, 2016 · 8 comments
Closed

Add Twig syntax check to Git pre-commit hook #44

TravisCarden opened this issue May 11, 2016 · 8 comments
Assignees
Labels
Enhancement A feature or feature request

Comments

@TravisCarden
Copy link
Contributor

TravisCarden commented May 11, 2016

Symfony2 provides a console command for syntax checking Twig templates:

# You can check by filename:
$ php bin/console lint:twig app/Resources/views/article/recent_list.html.twig

# or by directory:
$ php bin/console lint:twig app/Resources/views

We should consider adding this check to the Git pre-commit hook (and anywhere else we do linting).

@TravisCarden TravisCarden changed the title Check Twig syntax Add Twig syntax check to Git pre-commit hook May 11, 2016
@grasmash
Copy link
Contributor

Yay! I've been wanting to add this but I didn't know what tool would provide the linting.

@grasmash grasmash added the ready label Aug 9, 2016
@grasmash
Copy link
Contributor

@TravisCarden I don't appear to have a vendor/bin/console despite having symfony/console as a dependency. What package version are you using?

@TravisCarden
Copy link
Contributor Author

TravisCarden commented Aug 11, 2016

lint:twig is documented under the Templating component (symfony/templating). Perhaps it's provided separately by that? (I never implemented this. I just saw it in the documentation.)

@grasmash
Copy link
Contributor

grasmash commented Aug 15, 2016

Hm. Having trouble getting that binary to show up in the bin directory. Tried requiring both symfony/templating and symfony/console.

I wonder if we need to create a custom app and register those commands. It seems like that shouldn't be necessary.

@grasmash
Copy link
Contributor

Looks like this is part of symfony/symfony and is registered in https://github.com/symfony/symfony/blob/2.8/src/Symfony/Bridge/Twig/Command/LintCommand.php.

Maybe we should look at a lighter-weight solution like https://github.com/asm89/twig-lint.

grasmash added a commit to grasmash/bolt that referenced this issue Aug 15, 2016
@grasmash
Copy link
Contributor

So, lots of Symfony learning. Firstly, Symfony has a nightly build process that creates separate packagist projects for each component via git subtree. The lint command is part of symfony/twig-bridge.

The lint command can be registered with our own blt-console bin in one of two ways:

@grasmash grasmash self-assigned this Aug 15, 2016
@grasmash grasmash added in progress Enhancement A feature or feature request and removed ready labels Aug 15, 2016
@grasmash
Copy link
Contributor

grasmash commented Sep 2, 2016

Command was added but is not yet being executed in pre-commit hook.

@grasmash
Copy link
Contributor

Command currently exists in blt, ./vendor/bin/blt-console twig:lint --help

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

No branches or pull requests

2 participants