This shows you the differences between two versions of the page.
lint [2009/09/19 01:03] Kornel |
lint [2024/09/05 04:06] (current) 2605:7980:0:208d::1 1 |
||
---|---|---|---|
Line 3: | Line 3: | ||
Lint allows you to check syntax of templates (XML well-formedness) without running them. It is useful to run after [[Upgrading|upgrade]] of PHPTAL to ensure that everything still works. You can also use it in SVN pre-commit hook to prevent ill-formed templates from being committed to your repository. | Lint allows you to check syntax of templates (XML well-formedness) without running them. It is useful to run after [[Upgrading|upgrade]] of PHPTAL to ensure that everything still works. You can also use it in SVN pre-commit hook to prevent ill-formed templates from being committed to your repository. | ||
- | [https://svn.motion-twin.com/phptal/trunk/tools/phptal_lint.php|Download latest phptal_lint.php] | + | [[https://svn.motion-twin.com/phptal/trunk/tools/phptal_lint.php|Download latest phptal_lint.php]] |
- | ===== Usage ===== | ||
- | This is command-line tool. | + | ===== Installation ===== |
+ | |||
+ | |||
+ | ==== Unix & Mac OS X ==== | ||
+ | |||
+ | |||
+ | You can copy ''phptal_lint.php'' to directory in your path (e.g. ''/usr/local/bin''). Run ''echo $PATH'' to see which directories you have in path. | ||
+ | |||
+ | Or you can run it by always specifying full path to the ''phptal_lint.php'' file (most terminals support drag'n'drop, so just drop ''phptal_lint.php'' file into terminal window instead of typing entire path). | ||
+ | |||
+ | If you're getting errors that ''phptal_lint.php'' is not executable: | ||
+ | |||
+ | ''chmod a+rx /full/path/to/phptal_lint.php'' | ||
+ | |||
+ | If you're getting errors about missing interpreter, then use: | ||
+ | |||
+ | ''//php /full/path/to///phptal_lint.php'' | ||
+ | |||
+ | to run the tool. | ||
+ | |||
+ | ==== Windows ==== | ||
+ | |||
+ | C:\path\to\php.exe C:\path\to\phptal_lint.php | ||
+ | |||
+ | Running of this tool from ''%PATH%'' requires writing DOS batch file that passes arguments appropriately. | ||
+ | |||
+ | ===== Usage ===== | ||
phptal_lint.php [-e extensions] [-i php_file_or_directory] file_or_directory_to_check ... | phptal_lint.php [-e extensions] [-i php_file_or_directory] file_or_directory_to_check ... | ||
Line 13: | Line 38: | ||
- | * **-e** comma-separated list of file extensions you use for templates | + | * **''-e''** comma-separated list of file extensions you use for templates |
- | * **-i** path to PHP file or directory of PHP files to include (this is needed to check against your custom function modifiers) | + | * **''-i''** path to PHP file or directory of PHP files to include (this is needed to check against your [[http://phptal.org/manual/en/split/custom-modifiers.html|custom TALES modifiers]]) |
===== Examples ===== | ===== Examples ===== | ||
Line 20: | Line 45: | ||
phptal_lint.php . | phptal_lint.php . | ||
- | Scan current directory for all templates (templates are recognized by popular file extensions). TALES modifiers (as in ''%%${mycustommodifier:foo/bar}%%'') will be ignored. | + | Scan current directory for all templates (templates are recognized by popular file extensions). [[http://phptal.org/manual/en/split/custom-modifiers.html|TALES modifiers]] (as in ''%%${mycustommodifier:foo/bar}%%'') will be ignored. |
phptal_lint.php -e xhtml,zpt,tal,phtml -i myproject/includes/phptalmodifiers.php myproject/templates/ | phptal_lint.php -e xhtml,zpt,tal,phtml -i myproject/includes/phptalmodifiers.php myproject/templates/ | ||
- | Checks only *.xhtml, *.zpt, *.tal and *.phtml files in myproject/templates/. Will load myproject/includes/phptalmodifiers.php file first assuming it defines all TALES modifiers used by the templates. | + | Checks only ''*.xhtml'', ''*.zpt'', ''*.tal'' and ''*.phtml'' files in ''myproject/templates/''. Will load ''myproject/includes/phptalmodifiers.php'' file first assuming it defines all TALES modifiers used by the templates. |