guard-mthaml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -0
- data/lib/guard/mthaml.rb +140 -0
- data/lib/guard/mthaml/compiler/MtHaml.php +255 -0
- data/lib/guard/mthaml/templates/Guardfile +12 -0
- data/lib/guard/mthaml/version.rb +5 -0
- data/vendor/autoload.php +7 -0
- data/vendor/coffeescript/coffeescript/LICENSE +22 -0
- data/vendor/coffeescript/coffeescript/README.md +96 -0
- data/vendor/coffeescript/coffeescript/composer.json +23 -0
- data/vendor/coffeescript/coffeescript/grammar.y +309 -0
- data/vendor/coffeescript/coffeescript/make.php +115 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Compiler.php +76 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Error.php +15 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Helpers.php +116 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Init.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Lexer.php +1356 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Nodes.php +105 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Parser.php +3326 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Rewriter.php +552 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Scope.php +196 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/SyntaxError.php +9 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Value.php +20 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Access.php +31 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Arr.php +69 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Assign.php +353 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Base.php +288 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Block.php +294 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Call.php +283 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Class.php +282 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Closure.php +49 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Code.php +203 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Comment.php +39 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Existence.php +42 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Extends.php +26 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/For.php +250 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/If.php +161 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/In.php +99 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Index.php +27 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Literal.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Obj.php +126 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Op.php +292 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Param.php +119 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Parens.php +45 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Range.php +225 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Return.php +56 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Slice.php +47 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Splat.php +100 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Switch.php +121 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Throw.php +37 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Try.php +79 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Value.php +210 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/While.php +112 -0
- data/vendor/coffeescript/coffeescript/tests/cases/arrays.coffee +77 -0
- data/vendor/coffeescript/coffeescript/tests/cases/assignment.coffee +352 -0
- data/vendor/coffeescript/coffeescript/tests/cases/booleans.coffee +21 -0
- data/vendor/coffeescript/coffeescript/tests/cases/classes.coffee +681 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comments.coffee +207 -0
- data/vendor/coffeescript/coffeescript/tests/cases/compilation.coffee +72 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comprehensions.coffee +501 -0
- data/vendor/coffeescript/coffeescript/tests/cases/control_flow.coffee +430 -0
- data/vendor/coffeescript/coffeescript/tests/cases/eval.coffee +29 -0
- data/vendor/coffeescript/coffeescript/tests/cases/exception_handling.coffee +102 -0
- data/vendor/coffeescript/coffeescript/tests/cases/formatting.coffee +146 -0
- data/vendor/coffeescript/coffeescript/tests/cases/function_invocation.coffee +552 -0
- data/vendor/coffeescript/coffeescript/tests/cases/functions.coffee +188 -0
- data/vendor/coffeescript/coffeescript/tests/cases/helpers.coffee +96 -0
- data/vendor/coffeescript/coffeescript/tests/cases/importing.coffee +18 -0
- data/vendor/coffeescript/coffeescript/tests/cases/interpolation.coffee +138 -0
- data/vendor/coffeescript/coffeescript/tests/cases/javascript_literals.coffee +10 -0
- data/vendor/coffeescript/coffeescript/tests/cases/numbers.coffee +76 -0
- data/vendor/coffeescript/coffeescript/tests/cases/objects.coffee +271 -0
- data/vendor/coffeescript/coffeescript/tests/cases/operators.coffee +277 -0
- data/vendor/coffeescript/coffeescript/tests/cases/option_parser.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/ranges.coffee +88 -0
- data/vendor/coffeescript/coffeescript/tests/cases/regexps.coffee +63 -0
- data/vendor/coffeescript/coffeescript/tests/cases/scope.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/slicing_and_splicing.coffee +143 -0
- data/vendor/coffeescript/coffeescript/tests/cases/soaks.coffee +134 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strict.coffee +155 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strings.coffee +107 -0
- data/vendor/coffeescript/coffeescript/tests/css/style.css +43 -0
- data/vendor/coffeescript/coffeescript/tests/index.php +119 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.1.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.2.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/diff.js +276 -0
- data/vendor/coffeescript/coffeescript/tests/js/main.js +123 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/LICENSE.txt +10 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/Lempar.php +948 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Action.php +257 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/ActionTable.php +299 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Config.php +574 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Data.php +1857 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Parser.php +851 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/PropagationLink.php +126 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Rule.php +144 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/State.php +283 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Symbol.php +288 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/cli.php +5 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/ParserGenerator.php +811 -0
- data/vendor/composer/ClassLoader.php +383 -0
- data/vendor/composer/autoload_classmap.php +9 -0
- data/vendor/composer/autoload_namespaces.php +12 -0
- data/vendor/composer/autoload_psr4.php +10 -0
- data/vendor/composer/autoload_real.php +50 -0
- data/vendor/composer/installed.json +166 -0
- data/vendor/michelf/php-markdown/License.md +36 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +10 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.php +3117 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +11 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +38 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +9 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +37 -0
- data/vendor/michelf/php-markdown/Readme.md +305 -0
- data/vendor/michelf/php-markdown/Readme.php +31 -0
- data/vendor/michelf/php-markdown/composer.json +31 -0
- data/vendor/mthaml/mthaml/CHANGELOG +48 -0
- data/vendor/mthaml/mthaml/LICENSE +44 -0
- data/vendor/mthaml/mthaml/README.markdown +262 -0
- data/vendor/mthaml/mthaml/composer.json +45 -0
- data/vendor/mthaml/mthaml/docs/Makefile +153 -0
- data/vendor/mthaml/mthaml/docs/_static/mthaml.css +30 -0
- data/vendor/mthaml/mthaml/docs/_theme/mthaml/theme.conf +4 -0
- data/vendor/mthaml/mthaml/docs/conf.py +242 -0
- data/vendor/mthaml/mthaml/docs/index.rst +18 -0
- data/vendor/mthaml/mthaml/docs/twig-syntax.rst +274 -0
- data/vendor/mthaml/mthaml/examples/README.md +5 -0
- data/vendor/mthaml/mthaml/examples/autoload.php +8 -0
- data/vendor/mthaml/mthaml/examples/example-php.haml +5 -0
- data/vendor/mthaml/mthaml/examples/example-php.php +37 -0
- data/vendor/mthaml/mthaml/examples/example-twig-noext.twig +11 -0
- data/vendor/mthaml/mthaml/examples/example-twig.haml +9 -0
- data/vendor/mthaml/mthaml/examples/example-twig.php +60 -0
- data/vendor/mthaml/mthaml/examples/example.twig.haml +8 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Autoloader.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Environment.php +178 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Escaping.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception/SyntaxErrorException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/AbstractFilter.php +43 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Cdata.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/CoffeeScript.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Css.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Escaped.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/FilterInterface.php +15 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Javascript.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less.php +27 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/LeafoLess.php +20 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/OyejorgeLess.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +58 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CebeMarkdown.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Ciconia.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/MichelfMarkdown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Parsedown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Plain.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Preserve.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Scss.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Twig.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Indentation.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationInterface.php +50 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Undefined.php +41 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Comment.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Doctype.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/EscapableAbstract.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Filter.php +51 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Insert.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php +73 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestAbstract.php +117 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestInterface.php +10 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NodeAbstract.php +77 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefClass.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefId.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Root.php +35 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Run.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Statement.php +45 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Tag.php +90 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttribute.php +62 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeInterpolation.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeList.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Text.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Autoclose.php +25 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Escaping.php +105 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/MergeAttrs.php +110 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Midblock.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorAbstract.php +226 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorInterface.php +97 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/PhpRenderer.php +288 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Printer.php +265 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/RendererAbstract.php +581 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/TwigRenderer.php +252 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser.php +862 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser/Buffer.php +147 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime.php +218 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeInterpolation.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeList.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Php/Executor.php +157 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Extension.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Lexer.php +48 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Loader.php +81 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Php.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetAbstract.php +87 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetInterface.php +12 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Twig.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilder.php +100 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilderException.php +9 -0
- data/vendor/mthaml/mthaml/phpunit.xml +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/HamlSpecTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/IndentationTest.php +140 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/DoctypeTest.php +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/NodeTest.php +110 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/PhpRendererTest.php +113 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/TwigRendererTest.php +68 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitorsTest.php +44 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Parser/BufferTest.php +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/RuntimeTest.php +356 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Php/ExecutorTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Twig/LoaderTest.php +65 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCaseTest.php +50 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/Support/Php/Executor.001.haml +1 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_php.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_twig.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_php.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_twig.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_php.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_twig.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug42.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug8_twig.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/coffeescript_filter.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/comments.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/cond_cmt.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_html4.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid_xhtml.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_php.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_xhtml.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/filters.test +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_php.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_twig.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_php.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_twig.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_leafo.test +33 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_oyejorge.test +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_cebemarkdown.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_ciconia.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_michelf.test +34 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_parsedown.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_optimization_filter_michelf.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/mergeattrs.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_inner_whitespace.test +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_outer_whitespace.test +122 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_twig.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php.test +109 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping_once.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_filters.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/scss_filter.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/strip_inline_comments_php.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/test.test +24 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/trailing_semicolon_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/try_catch_php.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig.test +112 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_filters.test +37 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_whitespace.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/whitespace.test +63 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/autoclose.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_attr_once.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_html_false.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/mergeattrs.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock.test +54 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock_002.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attr_list.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_002.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_003.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_html_linebreak.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks.test +27 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks_002.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/boolean_attr.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug28.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug8.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/cond_cmt.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/doctype.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/double_equal.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/empty_line_after_multiline.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_001.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_002.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_003.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_004.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_005.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_006.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_007.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_008.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_009.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_010.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_013.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_016.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_017.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_018.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_019.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_020.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_002.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_003.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_004.test +21 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_005.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_006.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/insertflags.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation_in_html_attrs.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline_code.test +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiple_attr_kinds.test +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/non_rendered_comment.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ns.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error1.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error2.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/quotes_in_haml.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby19_attrs.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_001.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_002.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_003.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/standard.test +114 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/tagflags.test +39 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/php_filters.test +28 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/twig_filters.test +31 -0
- data/vendor/mthaml/mthaml/test/bootstrap.php +3 -0
- metadata +398 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bebf45e1efab70a01cc599778fbe9ba24b0de22e
|
4
|
+
data.tar.gz: 6e99eaac82f0d5f3b05edb178a9fc0c8e30bcce0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 333cb564784aa5ad1240b86042ce0a6c4b11873e7775eb35a6bd3cb248af5da2a9b536f1320cc20adad1d7ea8c3e2029a23be91041cc617de360e0df36d0b970
|
7
|
+
data.tar.gz: 04d110e33c81739fb7bcb626ab0b7bf5dac26a9ebc3acea718cda594376d5965761c3352d1786938f9103f60f91a24e39295d6790bbcdfe5f9dd5fe494d5d324
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Guard::MtHaml
|
2
|
+
This is a Guard wrapper to compile Haml to PHP, Twig or static HTML.
|
3
|
+
|
4
|
+
Add to your `Gemfile`:
|
5
|
+
```ruby
|
6
|
+
gem 'guard-mthaml'
|
7
|
+
```
|
8
|
+
|
9
|
+
Require in your `Guardfile`:
|
10
|
+
```ruby
|
11
|
+
require "guard/mthaml"
|
12
|
+
```
|
13
|
+
|
14
|
+
Or, add the default Guard::MtHaml template to your `Guardfile` by running:
|
15
|
+
```bash
|
16
|
+
$ guard init mthaml
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
###
|
23
|
+
# Sample Guardfile block for Guard::MtHaml
|
24
|
+
#
|
25
|
+
# :input ("views/src") set output directory for compiled files
|
26
|
+
# :output ("views") set input directory with haml files
|
27
|
+
# :environment ("php") haml environment
|
28
|
+
# :notifications (true) toggle guard notifications
|
29
|
+
# :compress_output (false) compress compiled haml files
|
30
|
+
# :static_files (false) compile haml to static html
|
31
|
+
# :run_at_start (true) compile files when guard starts
|
32
|
+
###
|
33
|
+
guard :haml, :input => "views/src", :output => "views"
|
34
|
+
```
|
data/lib/guard/mthaml.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require "guard"
|
2
|
+
require "guard/plugin"
|
3
|
+
require "guard/watcher"
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class MtHaml < Plugin
|
7
|
+
|
8
|
+
###
|
9
|
+
# Initializer
|
10
|
+
###
|
11
|
+
def initialize(options = {})
|
12
|
+
options = {
|
13
|
+
:input => "views/src",
|
14
|
+
:output => "views",
|
15
|
+
:environment => "php",
|
16
|
+
:notifications => true,
|
17
|
+
:compress_output => false,
|
18
|
+
:run_at_start => true,
|
19
|
+
:static_files => false
|
20
|
+
}.merge(options)
|
21
|
+
|
22
|
+
super(options)
|
23
|
+
|
24
|
+
if options[:input]
|
25
|
+
watchers << ::Guard::Watcher.new(%r{^#{options[:input]}/(.+\.haml)$})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
###
|
30
|
+
# Run at start
|
31
|
+
###
|
32
|
+
def start
|
33
|
+
run_all if options[:run_at_start]
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
def reload
|
41
|
+
run_all
|
42
|
+
end
|
43
|
+
|
44
|
+
###
|
45
|
+
# Run all
|
46
|
+
###
|
47
|
+
def run_all
|
48
|
+
run_on_changes Watcher.match_files(self, Dir.glob(File.join("**", "*.*")).reject { |f| f[%r{(\.php)$}] })
|
49
|
+
end
|
50
|
+
|
51
|
+
###
|
52
|
+
# Run on changes to watched files
|
53
|
+
#
|
54
|
+
# @param {Array} paths
|
55
|
+
# Paths of changed files
|
56
|
+
###
|
57
|
+
def run_on_changes(paths)
|
58
|
+
paths.each do |file|
|
59
|
+
|
60
|
+
file = Pathname.new(file)
|
61
|
+
file_dir = file.dirname.realpath
|
62
|
+
input_dir = Pathname.new(options[:input]).realpath
|
63
|
+
input_file = file.realpath
|
64
|
+
|
65
|
+
unless input_dir == file_dir
|
66
|
+
output_dir = Pathname.new(options[:output]).realpath + file_dir.basename
|
67
|
+
make_directory(output_dir)
|
68
|
+
else
|
69
|
+
output_dir = Pathname.new(options[:output]).realpath
|
70
|
+
end
|
71
|
+
|
72
|
+
compile_haml(input_file, output_dir)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
###
|
79
|
+
# Wrapper to run through PHP Haml compiler, which creates new files itself
|
80
|
+
#
|
81
|
+
# @param {String} input
|
82
|
+
# Input file to pass to compiler
|
83
|
+
# @param {String} output
|
84
|
+
# Output directory to pass to compiler
|
85
|
+
###
|
86
|
+
def compile_haml(input, output)
|
87
|
+
|
88
|
+
ext = if options[:static_files]
|
89
|
+
".html"
|
90
|
+
else
|
91
|
+
".#{options[:environment]}"
|
92
|
+
end
|
93
|
+
|
94
|
+
command = [
|
95
|
+
"php #{File.dirname(__FILE__)}/mthaml/compiler/MtHaml.php",
|
96
|
+
"--input #{input}",
|
97
|
+
"--output #{output}",
|
98
|
+
"--environment #{options[:environment]}",
|
99
|
+
"--static_files #{options[:static_files]}",
|
100
|
+
"--compress_output #{options[:compress_output]}"
|
101
|
+
].join " "
|
102
|
+
|
103
|
+
begin
|
104
|
+
throw :task_has_failed unless system command
|
105
|
+
::Guard::UI.info(color("write #{File.basename(input, ".*") + ext}", ";32")) if options[:notifications]
|
106
|
+
rescue StandardError => error
|
107
|
+
::Guard::UI.error(color("error #{File.basename(input, ".*") + ext} : #{error}", ";31")) if options[:notifications]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
###
|
112
|
+
# Create dir if it doesn't already exist, used to make sure the
|
113
|
+
# output file structure matches the input structure
|
114
|
+
#
|
115
|
+
# @param {String} dir
|
116
|
+
# Directory to create
|
117
|
+
###
|
118
|
+
def make_directory(dir)
|
119
|
+
unless File.directory? dir
|
120
|
+
FileUtils.mkdir_p(dir)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
###
|
125
|
+
# Set message color
|
126
|
+
#
|
127
|
+
# @param {String} message
|
128
|
+
# Text to color
|
129
|
+
# @param {String} color
|
130
|
+
# Color code
|
131
|
+
###
|
132
|
+
def color(message, color)
|
133
|
+
if ::Guard::UI.send(:color_enabled?)
|
134
|
+
"\e[0#{color}m#{message}\e[0m"
|
135
|
+
else
|
136
|
+
message
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace EGabrielse;
|
4
|
+
|
5
|
+
// Go up to root of plugin
|
6
|
+
require_once dirname(dirname(dirname(dirname(__DIR__)))) . "/vendor/autoload.php";
|
7
|
+
|
8
|
+
use MtHaml;
|
9
|
+
use Michelf\Markdown as Markdown;
|
10
|
+
use CoffeeScript\Compiler as CoffeeScript;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Compile Haml files locally. Used during development stages.
|
14
|
+
* Can minify compiled assets for production, as well as
|
15
|
+
* compile inline Markdown and CoffeeScript.
|
16
|
+
*
|
17
|
+
* @since 0.1.0
|
18
|
+
*/
|
19
|
+
class MtHamlCompiler {
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @var {String}
|
23
|
+
* Input filename that was passed into compiler
|
24
|
+
*
|
25
|
+
* @since 0.1.0
|
26
|
+
*/
|
27
|
+
private $input_file;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @var {String}
|
31
|
+
* Output directory to write compiled output to
|
32
|
+
*
|
33
|
+
* @since 0.1.0
|
34
|
+
*/
|
35
|
+
private $output_dir;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @var {String}
|
39
|
+
* Type of MtHaml environment, either Twig or PHP
|
40
|
+
*
|
41
|
+
* @since 0.1.0
|
42
|
+
*/
|
43
|
+
private $environment;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @var {Array}
|
47
|
+
* Array of options to be passed to MtHaml
|
48
|
+
*
|
49
|
+
* @since 0.1.0
|
50
|
+
*/
|
51
|
+
private $options;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @var {Array}
|
55
|
+
* Array containing Haml filters and their instances
|
56
|
+
*
|
57
|
+
* @since 0.1.0
|
58
|
+
*/
|
59
|
+
private $filters;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @var {Object}
|
63
|
+
* Instance of \MtHaml\Environment
|
64
|
+
*
|
65
|
+
* @since 0.1.0
|
66
|
+
*/
|
67
|
+
private $compiler;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @var {String}
|
71
|
+
* Compiled output of Haml file
|
72
|
+
*
|
73
|
+
* @since 0.1.0
|
74
|
+
*/
|
75
|
+
private $output;
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Constructor
|
79
|
+
*
|
80
|
+
* @param {Array} $opts
|
81
|
+
* Array that contains input file and output directory
|
82
|
+
*
|
83
|
+
* @since 0.1.0
|
84
|
+
*/
|
85
|
+
public function __construct( $opts = array() ) {
|
86
|
+
|
87
|
+
// Set filters
|
88
|
+
$this->filters["markdown"] = new \MtHaml\Filter\Markdown\MichelfMarkdown( new Markdown );
|
89
|
+
$this->filters["coffeescript"] = new \MtHaml\Filter\CoffeeScript( new CoffeeScript(), array( "header" => false ) );
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Get the input file
|
93
|
+
*/
|
94
|
+
if( isset( $opts['input'] ) ) {
|
95
|
+
$this->input_file = $opts['input'];
|
96
|
+
} else {
|
97
|
+
throw new \Exception( "No input file was passed into \$opts." );
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Get the output dir
|
102
|
+
*/
|
103
|
+
if( isset( $opts['output'] ) ) {
|
104
|
+
$this->output_dir = $opts["output"];
|
105
|
+
} else {
|
106
|
+
throw new \Exception( "No output directory was passed into \$opts." );
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Make sure an options map was passed
|
111
|
+
*/
|
112
|
+
if( isset( $opts['options'] ) ) {
|
113
|
+
$this->options = $opts['options'];
|
114
|
+
} else {
|
115
|
+
throw new \Exception( "No options were passed into \$opts." );
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Get the environment
|
120
|
+
*/
|
121
|
+
if( isset( $this->options['environment'] ) ) {
|
122
|
+
$this->environment = $this->options['environment'];
|
123
|
+
} else {
|
124
|
+
throw new \Exception( "No environment was passed into \$opts." );
|
125
|
+
}
|
126
|
+
|
127
|
+
// Set the MtHaml environment
|
128
|
+
self::set_environment();
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Runs compiler and writes contents to output file
|
133
|
+
*
|
134
|
+
* @since 0.1.0
|
135
|
+
*/
|
136
|
+
public function run() {
|
137
|
+
// Compile output
|
138
|
+
$this->output = $this->compile();
|
139
|
+
// Compress output if set
|
140
|
+
if( $this->options["compress_output"] ) {
|
141
|
+
$this->output = $this->compress();
|
142
|
+
}
|
143
|
+
// Write output to file
|
144
|
+
$this->write();
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Create HtHaml environment
|
149
|
+
*
|
150
|
+
* @since 0.1.0
|
151
|
+
*/
|
152
|
+
private function set_environment() {
|
153
|
+
$this->compiler = new \MtHaml\Environment( $this->environment, array(
|
154
|
+
'enable_dynamic_attrs' => false,
|
155
|
+
"enable_escaper" => false,
|
156
|
+
"cdata" => false
|
157
|
+
), array(
|
158
|
+
"markdown" => $this->filters["markdown"],
|
159
|
+
"coffeescript" => $this->filters["coffeescript"],
|
160
|
+
));
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Instantiate MtHaml and compile passed file
|
165
|
+
*
|
166
|
+
* @since 0.1.0
|
167
|
+
*/
|
168
|
+
private function compile() {
|
169
|
+
if ( $this->options["static_files"] ) {
|
170
|
+
// Instantiate executor based on environment
|
171
|
+
if ( $this->environment == "php" ) {
|
172
|
+
$this->executor = new \MtHaml\Support\Php\Executor( $this->compiler, array(
|
173
|
+
"cache" => $this->output_dir . '/cache',
|
174
|
+
));
|
175
|
+
} else {
|
176
|
+
throw new \Exception("To compile static files, please set your environment to PHP. It is currently set to `$this->environment`.");
|
177
|
+
}
|
178
|
+
// Compile assets
|
179
|
+
return $this->executor->render( $this->input_file, array() );
|
180
|
+
} else {
|
181
|
+
// Get contents from input file and compile
|
182
|
+
return $this->compiler->compileString( file_get_contents( $this->input_file ), basename( $this->input_file ) );
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Removes all white space and newlines from output
|
188
|
+
*
|
189
|
+
* @TODO Find a Composer plugin that will do this, as this isn't very clean
|
190
|
+
*
|
191
|
+
* @since 0.1.0
|
192
|
+
*/
|
193
|
+
private function compress() {
|
194
|
+
return preg_replace( "/^\s+|\n|\r|\s+$/m", "", $this->output );
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Make sure that the path is writable
|
199
|
+
*
|
200
|
+
* @param {String} $dir
|
201
|
+
* Directory path
|
202
|
+
*
|
203
|
+
* @since 0.1.0
|
204
|
+
*/
|
205
|
+
private function ensure_path_writable( $dir ) {
|
206
|
+
// Attempt to change permissions if not writable
|
207
|
+
if ( ! is_writable( $dir ) ) {
|
208
|
+
chmod( $dir, 0760 );
|
209
|
+
}
|
210
|
+
// If dir is still not writable, throw err
|
211
|
+
if ( ! is_writable( $dir ) ) {
|
212
|
+
throw new \Exception("It looks like the directory `$dir` isn't writable.");
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Writes compiled assets to output file
|
218
|
+
*
|
219
|
+
* @since 0.1.0
|
220
|
+
*/
|
221
|
+
private function write() {
|
222
|
+
if ( $this->output ) {
|
223
|
+
$extension = $this->options["static_files"] ? "html" : $this->environment;
|
224
|
+
// Make sure our path is writable
|
225
|
+
self::ensure_path_writable( $this->output_dir );
|
226
|
+
// Render output
|
227
|
+
return file_put_contents( "$this->output_dir/" . basename( $this->input_file, ".haml" ) . ".$extension", $this->output );
|
228
|
+
} else {
|
229
|
+
throw new \Exception( "It looks like `" . basename( $this->input_file ) . "` compiled without any output." );
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Get passed arguments from Guard
|
236
|
+
*/
|
237
|
+
$opts = getopt( "", array( "input:", "output:", "environment:", "static_files:", "compress_output:" ) );
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Instantiate compiler and parse file with input from Guard
|
241
|
+
*/
|
242
|
+
try {
|
243
|
+
$compiler = new MtHamlCompiler( array(
|
244
|
+
"input" => $opts["input"],
|
245
|
+
"output" => $opts["output"],
|
246
|
+
"options" => array(
|
247
|
+
"environment" => $opts["environment"],
|
248
|
+
"static_files" => $opts["static_files"] === "true" ? true : false,
|
249
|
+
"compress_output" => $opts["compress_output"] === "true" ? true : false
|
250
|
+
)
|
251
|
+
));
|
252
|
+
$compiler->run();
|
253
|
+
} catch ( \Exception $err ) {
|
254
|
+
exit ( $err->getMessage() . "\n" );
|
255
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
###
|
2
|
+
# Sample Guardfile block for Guard::MtHaml
|
3
|
+
#
|
4
|
+
# :input ("views/src") set output directory for compiled files
|
5
|
+
# :output ("views") set input directory with haml files
|
6
|
+
# :environment ("php") haml environment
|
7
|
+
# :notifications (true) toggle guard notifications
|
8
|
+
# :compress_output (false) compress compiled haml files
|
9
|
+
# :static_files (false) compile haml to static html
|
10
|
+
# :run_at_start (true) compile files when guard starts
|
11
|
+
###
|
12
|
+
guard :mthaml, :input => "views/src", :output => "views"
|