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
@@ -0,0 +1,113 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests\NodeVisitor;
|
4
|
+
|
5
|
+
use MtHaml\NodeVisitor\PhpRenderer;
|
6
|
+
use MtHaml\Environment;
|
7
|
+
use MtHaml\Node\InterpolatedString;
|
8
|
+
use MtHaml\Node\Text;
|
9
|
+
|
10
|
+
class PhpRendererTest extends \PHPUnit_Framework_TestCase
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* @dataProvider getTestTrimInlineCommentsData
|
14
|
+
*/
|
15
|
+
public function testTrimInlineComments($expect, $code)
|
16
|
+
{
|
17
|
+
$env = new Environment('php');
|
18
|
+
$renderer = new PhpRenderer($env);
|
19
|
+
$result = $renderer->trimInlineComments($code);
|
20
|
+
$this->assertSame($expect, $result);
|
21
|
+
}
|
22
|
+
|
23
|
+
public function getTestTrimInlineCommentsData()
|
24
|
+
{
|
25
|
+
return array(
|
26
|
+
'no comments' => array('1 + 2', '1 + 2'),
|
27
|
+
'# comment' => array('1 + 2', '1 + 2 # comment'),
|
28
|
+
'// comment' => array('1 + 2', '1 + 2 // comment'),
|
29
|
+
'comment without whitespace' => array('1 + 2', '1 + 2// comment'),
|
30
|
+
|
31
|
+
'double quoted string' => array(
|
32
|
+
'"foo"', '"foo" # bar'
|
33
|
+
),
|
34
|
+
'double quoted string with escapes' => array(
|
35
|
+
'"f\\\\o\\"o\n"', '"f\\\\o\\"o\n" # bar'
|
36
|
+
),
|
37
|
+
'single quoted string' => array(
|
38
|
+
'\'foo\'', '\'foo\' # bar'
|
39
|
+
),
|
40
|
+
'single quoted string with escapes' => array(
|
41
|
+
'\'f\\\\o\\\'o\'', '\'f\\\\o\\\'o\' # bar'
|
42
|
+
),
|
43
|
+
'backticks string' => array(
|
44
|
+
'`foo`', '`foo` # bar'
|
45
|
+
),
|
46
|
+
'backticks string with escapes' => array(
|
47
|
+
'`f\\\\o\\`o`', '`f\\\\o\\`o` # bar'
|
48
|
+
),
|
49
|
+
'double quoted string with #' => array(
|
50
|
+
'"fo#o"', '"fo#o" # bar'
|
51
|
+
),
|
52
|
+
'# in comment' => array(
|
53
|
+
'"foo"', '"foo" # b # a # r'
|
54
|
+
),
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
58
|
+
/** @dataProvider getPhpOpenTagsAreEscapedData */
|
59
|
+
public function testPhpOpenTagsAreEscaped($expect, $node)
|
60
|
+
{
|
61
|
+
$env = $this->getMockBuilder('MtHaml\Environment')
|
62
|
+
->disableOriginalConstructor()
|
63
|
+
->getMock();
|
64
|
+
|
65
|
+
$r = new PhpRenderer($env);
|
66
|
+
|
67
|
+
$node = $node();
|
68
|
+
$node->accept($r);
|
69
|
+
|
70
|
+
$output = $r->getOutput();
|
71
|
+
$this->assertSame($expect, $output);
|
72
|
+
}
|
73
|
+
|
74
|
+
public function getPhpOpenTagsAreEscapedData()
|
75
|
+
{
|
76
|
+
$pos = array(0, 0);
|
77
|
+
|
78
|
+
return array(
|
79
|
+
'middle' => array(
|
80
|
+
'expect' => "foo <?php echo '<?'; ?> bar",
|
81
|
+
'node' => function () use ($pos) {
|
82
|
+
return new Text($pos, "foo <? bar");
|
83
|
+
},
|
84
|
+
),
|
85
|
+
'? leading in node, not preceeded by <' => array(
|
86
|
+
'expect' => "foo ? bar",
|
87
|
+
'nodes' => function () use ($pos) {
|
88
|
+
return new InterpolatedString($pos, array(
|
89
|
+
new Text($pos, 'foo '),
|
90
|
+
new Text($pos, '? bar'),
|
91
|
+
));
|
92
|
+
},
|
93
|
+
),
|
94
|
+
'? leading in node, preceeded by <' => array(
|
95
|
+
'expect' => "foo <<?php echo '?'; ?> bar",
|
96
|
+
'nodes' => function () use ($pos) {
|
97
|
+
return new InterpolatedString($pos, array(
|
98
|
+
new Text($pos, 'foo <'),
|
99
|
+
new Text($pos, '? bar'),
|
100
|
+
));
|
101
|
+
},
|
102
|
+
),
|
103
|
+
'? leading in node, globally leading' => array(
|
104
|
+
'expect' => "<?php echo '?'; ?> bar",
|
105
|
+
'nodes' => function () use ($pos) {
|
106
|
+
return new InterpolatedString($pos, array(
|
107
|
+
new Text($pos, '? bar'),
|
108
|
+
));
|
109
|
+
},
|
110
|
+
),
|
111
|
+
);
|
112
|
+
}
|
113
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests\NodeVisitor;
|
4
|
+
|
5
|
+
use MtHaml\Node\Text;
|
6
|
+
use MtHaml\NodeVisitor\TwigRenderer;
|
7
|
+
use MtHaml\Node\InterpolatedString;
|
8
|
+
|
9
|
+
class TwigRendererTest extends \PHPUnit_Framework_TestCase
|
10
|
+
{
|
11
|
+
/** @dataProvider getCurlyPercentAndCurlyCurclyAreEscapedData */
|
12
|
+
public function testCurlyPercentAndCurlyCurclyAreEscaped($expect, $node)
|
13
|
+
{
|
14
|
+
$env = $this->getMockBuilder('MtHaml\Environment')
|
15
|
+
->disableOriginalConstructor()
|
16
|
+
->getMock();
|
17
|
+
|
18
|
+
$r = new TwigRenderer($env);
|
19
|
+
|
20
|
+
$node = $node();
|
21
|
+
$node->accept($r);
|
22
|
+
|
23
|
+
$output = $r->getOutput();
|
24
|
+
$this->assertSame($expect, $output);
|
25
|
+
}
|
26
|
+
|
27
|
+
public function getCurlyPercentAndCurlyCurclyAreEscapedData()
|
28
|
+
{
|
29
|
+
$pos = array(0, 0);
|
30
|
+
|
31
|
+
return array(
|
32
|
+
'middle' => array(
|
33
|
+
'expect' => "foo {{ '{{' }} bar {{ '{%' }} baz",
|
34
|
+
'node' => function () use ($pos) {
|
35
|
+
return new Text($pos, "foo {{ bar {% baz");
|
36
|
+
},
|
37
|
+
),
|
38
|
+
'leading in node, not preceeded by {' => array(
|
39
|
+
'expect' => "foo % bar { baz",
|
40
|
+
'nodes' => function () use ($pos) {
|
41
|
+
return new InterpolatedString($pos, array(
|
42
|
+
new Text($pos, 'foo '),
|
43
|
+
new Text($pos, '% bar '),
|
44
|
+
new Text($pos, '{ baz'),
|
45
|
+
));
|
46
|
+
},
|
47
|
+
),
|
48
|
+
'leading in node, preceeded by {' => array(
|
49
|
+
'expect' => "foo {{{ '%' }} bar {{{ '{' }} baz",
|
50
|
+
'nodes' => function () use ($pos) {
|
51
|
+
return new InterpolatedString($pos, array(
|
52
|
+
new Text($pos, 'foo {'),
|
53
|
+
new Text($pos, '% bar {'),
|
54
|
+
new Text($pos, '{ baz'),
|
55
|
+
));
|
56
|
+
},
|
57
|
+
),
|
58
|
+
'leading in node, globally leading' => array(
|
59
|
+
'expect' => "{{ '%' }} bar",
|
60
|
+
'nodes' => function () use ($pos) {
|
61
|
+
return new InterpolatedString($pos, array(
|
62
|
+
new Text($pos, '% bar'),
|
63
|
+
));
|
64
|
+
},
|
65
|
+
),
|
66
|
+
);
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests;
|
4
|
+
|
5
|
+
use MtHaml\NodeVisitor\Printer;
|
6
|
+
use MtHaml\Parser;
|
7
|
+
|
8
|
+
require_once __DIR__ . '/TestCase.php';
|
9
|
+
|
10
|
+
class NodeVisitorsTest extends TestCase
|
11
|
+
{
|
12
|
+
/** @dataProvider getAutocloseFixtures */
|
13
|
+
public function testAutoclose($file)
|
14
|
+
{
|
15
|
+
$parts = $this->parseTestFile($file);
|
16
|
+
|
17
|
+
try {
|
18
|
+
$parser = new Parser;
|
19
|
+
$node = $parser->parse($parts['HAML'], $file, 2);
|
20
|
+
|
21
|
+
eval($parts['FILE']);
|
22
|
+
|
23
|
+
$renderer = new Printer;
|
24
|
+
$node->accept($renderer);
|
25
|
+
} catch (\Exception $e) {
|
26
|
+
return $this->assertException($parts, $e);
|
27
|
+
}
|
28
|
+
$this->assertException($parts);
|
29
|
+
|
30
|
+
file_put_contents($file . '.out', $renderer->getOutput());
|
31
|
+
|
32
|
+
$this->assertSame($parts['EXPECT'], $renderer->getOutput());
|
33
|
+
|
34
|
+
unlink($file . '.out');
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
public function getAutocloseFixtures()
|
39
|
+
{
|
40
|
+
return array_map(function ($file) {
|
41
|
+
return array($file);
|
42
|
+
}, glob(__DIR__ . '/fixtures/nodevisitors/*.test'));
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests\Parser;
|
4
|
+
|
5
|
+
use MtHaml\Parser\Buffer;
|
6
|
+
|
7
|
+
class BufferTest extends \PHPUnit_Framework_TestCase
|
8
|
+
{
|
9
|
+
public function testSimple()
|
10
|
+
{
|
11
|
+
$buffer = new Buffer(" abc\n def\nghi");
|
12
|
+
|
13
|
+
$this->assertTrue($buffer->nextLine());
|
14
|
+
$this->assertSame(" abc", $buffer->getLine());
|
15
|
+
|
16
|
+
$this->assertTrue($buffer->match('~z*~A', $match));
|
17
|
+
$this->assertSame(array(
|
18
|
+
'',
|
19
|
+
'pos' => array(
|
20
|
+
array('lineno' => 1, 'column' => 0),
|
21
|
+
),
|
22
|
+
), $match);
|
23
|
+
$this->assertSame(" abc", $buffer->getLine());
|
24
|
+
|
25
|
+
$this->assertTrue($buffer->match('~(\s*)(a)~A', $match));
|
26
|
+
$this->assertSame(array(
|
27
|
+
' a',
|
28
|
+
' ',
|
29
|
+
'a',
|
30
|
+
'pos' => array(
|
31
|
+
array('lineno' => 1, 'column' => 0),
|
32
|
+
array('lineno' => 1, 'column' => 0),
|
33
|
+
array('lineno' => 1, 'column' => 2),
|
34
|
+
),
|
35
|
+
), $match);
|
36
|
+
$this->assertSame("bc", $buffer->getLine());
|
37
|
+
|
38
|
+
$this->assertTrue($buffer->nextLine());
|
39
|
+
$this->assertSame(" def", $buffer->getLine());
|
40
|
+
$this->assertSame(2, $buffer->getLineno());
|
41
|
+
|
42
|
+
$this->assertSame(' ', $buffer->peekChar());
|
43
|
+
$this->assertSame(" def", $buffer->getLine());
|
44
|
+
$this->assertSame(1, $buffer->getColumn());
|
45
|
+
|
46
|
+
$this->assertSame(' ', $buffer->eatChar());
|
47
|
+
$this->assertSame(" def", $buffer->getLine());
|
48
|
+
$this->assertSame(2, $buffer->getColumn());
|
49
|
+
|
50
|
+
$buffer->skipWs();
|
51
|
+
$this->assertSame('def', $buffer->getLine());
|
52
|
+
$this->assertSame(5, $buffer->getColumn());
|
53
|
+
|
54
|
+
$this->assertTrue($buffer->nextLine());
|
55
|
+
$this->assertSame('ghi', $buffer->getLine());
|
56
|
+
$this->assertSame(3, $buffer->getLineno());
|
57
|
+
|
58
|
+
$this->assertFalse($buffer->nextLine());
|
59
|
+
}
|
60
|
+
|
61
|
+
public function testEatChars()
|
62
|
+
{
|
63
|
+
$buffer = new Buffer("abcdef");
|
64
|
+
|
65
|
+
$buffer->nextLine();
|
66
|
+
|
67
|
+
$chars = $buffer->eatChars(2);
|
68
|
+
$this->assertSame("ab", $chars);
|
69
|
+
$this->assertSame("cdef", $buffer->getLine());
|
70
|
+
$this->assertSame(3, $buffer->getColumn());
|
71
|
+
|
72
|
+
$chars = $buffer->eatChars(5);
|
73
|
+
$this->assertSame("cdef", $chars);
|
74
|
+
$this->assertSame("", $buffer->getLine());
|
75
|
+
$this->assertSame(7, $buffer->getColumn());
|
76
|
+
}
|
77
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests;
|
4
|
+
|
5
|
+
use MtHaml\Parser;
|
6
|
+
use MtHaml\NodeVisitor\Printer;
|
7
|
+
|
8
|
+
require_once __DIR__ . '/TestCase.php';
|
9
|
+
|
10
|
+
class ParserTest extends TestCase
|
11
|
+
{
|
12
|
+
/** @dataProvider getParserFixtures */
|
13
|
+
public function testParser($file)
|
14
|
+
{
|
15
|
+
$parts = $this->parseTestFile($file);
|
16
|
+
|
17
|
+
try {
|
18
|
+
$parser = new Parser;
|
19
|
+
$node = $parser->parse($parts['HAML'], $file, 2);
|
20
|
+
|
21
|
+
$renderer = new Printer;
|
22
|
+
$node->accept($renderer);
|
23
|
+
} catch (\Exception $e) {
|
24
|
+
return $this->assertException($parts, $e);
|
25
|
+
}
|
26
|
+
$this->assertException($parts);
|
27
|
+
|
28
|
+
file_put_contents($file . '.out', $renderer->getOutput());
|
29
|
+
|
30
|
+
$this->assertSame($parts['EXPECT'], $renderer->getOutput());
|
31
|
+
|
32
|
+
unlink($file . '.out');
|
33
|
+
}
|
34
|
+
|
35
|
+
public function getParserFixtures()
|
36
|
+
{
|
37
|
+
if (false !== $tests = getenv('PARSER_TESTS')) {
|
38
|
+
$files = explode(' ', $tests);
|
39
|
+
} else {
|
40
|
+
$files = glob(__DIR__ . '/fixtures/parser/*.test');
|
41
|
+
}
|
42
|
+
|
43
|
+
return array_map(function ($file) {
|
44
|
+
return array($file);
|
45
|
+
}, $files);
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,356 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
namespace MtHaml\Tests {
|
4
|
+
|
5
|
+
use MtHaml\Runtime;
|
6
|
+
use MtHaml\Runtime\AttributeList;
|
7
|
+
|
8
|
+
require_once __DIR__ . '/TestCase.php';
|
9
|
+
|
10
|
+
class RuntimeTest extends TestCase
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* @dataProvider getTestRenderAttributesData
|
14
|
+
*/
|
15
|
+
public function testRenderAttributes($expect, $list, $format = 'html5', $charset = 'utf-8')
|
16
|
+
{
|
17
|
+
$result = Runtime::renderAttributes($list, $format, $charset);
|
18
|
+
$this->assertSame($expect, $result);
|
19
|
+
}
|
20
|
+
|
21
|
+
public function getTestRenderAttributesData()
|
22
|
+
{
|
23
|
+
return array(
|
24
|
+
'simple' => array(
|
25
|
+
'foo="bar" bar="baz"',
|
26
|
+
array(
|
27
|
+
array('foo', 'bar'),
|
28
|
+
array('bar', 'baz'),
|
29
|
+
),
|
30
|
+
),
|
31
|
+
'duplicate attribute' => array(
|
32
|
+
'bar="baz" foo="qux"',
|
33
|
+
array(
|
34
|
+
array('foo', 'bar'),
|
35
|
+
array('bar', 'baz'),
|
36
|
+
array('foo', 'qux'),
|
37
|
+
),
|
38
|
+
),
|
39
|
+
'data attribute' => array(
|
40
|
+
'foo="bar" data-a="A" data-b="B"',
|
41
|
+
array(
|
42
|
+
array('foo', 'bar'),
|
43
|
+
array('data', array('a' => 'A', 'b' => 'B')),
|
44
|
+
),
|
45
|
+
),
|
46
|
+
'previous data attribute overridden by specific data- attribute' => array(
|
47
|
+
'foo="bar" data-b="B" data-a="A2"',
|
48
|
+
array(
|
49
|
+
array('foo', 'bar'),
|
50
|
+
array('data', array('a' => 'A', 'b' => 'B')),
|
51
|
+
array('data-a', 'A2'),
|
52
|
+
),
|
53
|
+
),
|
54
|
+
'previous data- attribute not overridden by data attribute list' => array(
|
55
|
+
'foo="bar" data-a="A2" data-b="B"',
|
56
|
+
array(
|
57
|
+
array('foo', 'bar'),
|
58
|
+
array('data-a', 'A2'),
|
59
|
+
array('data', array('a' => 'A', 'b' => 'B')),
|
60
|
+
),
|
61
|
+
),
|
62
|
+
'deeply nested data attribute' => array(
|
63
|
+
'foo="bar" data-a="A" data-b="B" data-c-d-e-f="F" data-c-g="G"',
|
64
|
+
array(
|
65
|
+
array('foo', 'bar'),
|
66
|
+
array('data', array(
|
67
|
+
'a' => 'A',
|
68
|
+
'b' => 'B',
|
69
|
+
'c' => array(
|
70
|
+
'd' => array(
|
71
|
+
'e' => array(
|
72
|
+
'f' => 'F',
|
73
|
+
),
|
74
|
+
),
|
75
|
+
'g' => 'G',
|
76
|
+
),
|
77
|
+
)),
|
78
|
+
),
|
79
|
+
),
|
80
|
+
'single id attribute' => array(
|
81
|
+
'id="a"',
|
82
|
+
array(
|
83
|
+
array('id', 'a'),
|
84
|
+
),
|
85
|
+
),
|
86
|
+
'multiple id attributes are joined with _' => array(
|
87
|
+
'id="a_b"',
|
88
|
+
array(
|
89
|
+
array('id', 'a'),
|
90
|
+
array('id', 'b'),
|
91
|
+
),
|
92
|
+
),
|
93
|
+
'multiple id attributes skip nulls and falses' => array(
|
94
|
+
'id="a_b"',
|
95
|
+
array(
|
96
|
+
array('id', 'a'),
|
97
|
+
array('id', null),
|
98
|
+
array('id', false),
|
99
|
+
array('id', 'b'),
|
100
|
+
),
|
101
|
+
),
|
102
|
+
'id attributes recurse' => array(
|
103
|
+
'id="a_b_c_d_e_f"',
|
104
|
+
array(
|
105
|
+
array('id', 'a'),
|
106
|
+
array('id', array('b', null, 'c')),
|
107
|
+
array('id', array('d', array('e', 'f'))),
|
108
|
+
),
|
109
|
+
),
|
110
|
+
'single class attribute' => array(
|
111
|
+
'class="a"',
|
112
|
+
array(
|
113
|
+
array('class', 'a'),
|
114
|
+
),
|
115
|
+
),
|
116
|
+
'multiple class attributes are joined with _' => array(
|
117
|
+
'class="a b"',
|
118
|
+
array(
|
119
|
+
array('class', 'a'),
|
120
|
+
array('class', 'b'),
|
121
|
+
),
|
122
|
+
),
|
123
|
+
'multiple class attributes skip nulls and falses' => array(
|
124
|
+
'class="a b"',
|
125
|
+
array(
|
126
|
+
array('class', 'a'),
|
127
|
+
array('class', null),
|
128
|
+
array('class', false),
|
129
|
+
array('class', 'b'),
|
130
|
+
),
|
131
|
+
),
|
132
|
+
'class attributes recurse' => array(
|
133
|
+
'class="a b c d e f"',
|
134
|
+
array(
|
135
|
+
array('class', 'a'),
|
136
|
+
array('class', array('b', null, 'c')),
|
137
|
+
array('class', array('d', array('e', 'f'))),
|
138
|
+
),
|
139
|
+
),
|
140
|
+
'boolean attributes are rendered without value in html5 format' => array(
|
141
|
+
'foo',
|
142
|
+
array(
|
143
|
+
array('foo', true),
|
144
|
+
),
|
145
|
+
),
|
146
|
+
'boolean attributes are rendered with value in xhtml format' => array(
|
147
|
+
'foo="foo"',
|
148
|
+
array(
|
149
|
+
array('foo', true),
|
150
|
+
),
|
151
|
+
'xhtml',
|
152
|
+
),
|
153
|
+
'false and null attributes are not rendered' => array(
|
154
|
+
null,
|
155
|
+
array(
|
156
|
+
array('foo', null),
|
157
|
+
array('bar', false),
|
158
|
+
),
|
159
|
+
),
|
160
|
+
'everything is escaped' => array(
|
161
|
+
'foo>="bar>" data-foo>="bar>" data-bar>="bar>" id="bar>" class="bar>"',
|
162
|
+
array(
|
163
|
+
array('foo>', 'bar>'),
|
164
|
+
array('data', array('foo>' => 'bar>')),
|
165
|
+
array('data-bar>', 'bar>'),
|
166
|
+
array('id', array('bar>')),
|
167
|
+
array('class', array('bar>')),
|
168
|
+
),
|
169
|
+
),
|
170
|
+
'attribute list' => array(
|
171
|
+
'foo="bar" bar="baz" baz="qux" all="ok"',
|
172
|
+
array(
|
173
|
+
array('foo', 'bar'),
|
174
|
+
AttributeList::create(array(
|
175
|
+
'bar' => 'baz',
|
176
|
+
'baz' => 'qux',
|
177
|
+
)),
|
178
|
+
array('all', 'ok'),
|
179
|
+
),
|
180
|
+
),
|
181
|
+
'attribute list are properly merged' => array(
|
182
|
+
'class="foo bar" id="x_43" all="ok"',
|
183
|
+
array(
|
184
|
+
array('class', 'foo'),
|
185
|
+
array('id', 'x'),
|
186
|
+
AttributeList::create(array(
|
187
|
+
'class' => 'bar',
|
188
|
+
'id' => '43',
|
189
|
+
)),
|
190
|
+
array('all', 'ok'),
|
191
|
+
),
|
192
|
+
),
|
193
|
+
);
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* @dataProvider getObjectRefClassStringData
|
198
|
+
*/
|
199
|
+
public function testGetObjectRefClassStringData($expect, $class)
|
200
|
+
{
|
201
|
+
$result = Runtime::getObjectRefClassString(new $class);
|
202
|
+
$this->assertSame($expect, $result);
|
203
|
+
}
|
204
|
+
|
205
|
+
public function getObjectRefClassStringData()
|
206
|
+
{
|
207
|
+
return array(
|
208
|
+
'simple' => array('foo_bar', 'FooBar'),
|
209
|
+
'underscores in name' => array('foo_bar', 'Foo_Bar'),
|
210
|
+
'multiple upper case' => array('foo_bbar', 'FooBBar'),
|
211
|
+
'namespace' => array('baz_qux', 'Foo\Bar\BazQux'),
|
212
|
+
);
|
213
|
+
}
|
214
|
+
|
215
|
+
public function testRenderObjectRefClass()
|
216
|
+
{
|
217
|
+
$object = new \stdClass;
|
218
|
+
$result = Runtime::renderObjectRefClass($object);
|
219
|
+
$this->assertSame('std_class', $result);
|
220
|
+
|
221
|
+
$object = new \stdClass;
|
222
|
+
$result = Runtime::renderObjectRefClass($object, 'pref<');
|
223
|
+
$this->assertSame('pref<_std_class', $result);
|
224
|
+
}
|
225
|
+
|
226
|
+
public function testRenderObjectRefId()
|
227
|
+
{
|
228
|
+
$object = new ObjectRefWithGetIdAndId;
|
229
|
+
$result = Runtime::renderObjectRefId($object);
|
230
|
+
$this->assertSame('object_ref_with_get_id_and_id_>get_id', $result);
|
231
|
+
|
232
|
+
$object = new ObjectRefWithGetIdAndId;
|
233
|
+
$result = Runtime::renderObjectRefId($object, 'pref<');
|
234
|
+
$this->assertSame('pref<_object_ref_with_get_id_and_id_>get_id', $result);
|
235
|
+
|
236
|
+
$object = new ObjectRefWithId;
|
237
|
+
$result = Runtime::renderObjectRefId($object);
|
238
|
+
$this->assertSame('object_ref_with_id_>id', $result);
|
239
|
+
|
240
|
+
$object = new ObjectRefWithGetIdAndId;
|
241
|
+
$object->getId = null;
|
242
|
+
$result = Runtime::renderObjectRefId($object);
|
243
|
+
$this->assertSame('object_ref_with_get_id_and_id_new', $result);
|
244
|
+
}
|
245
|
+
|
246
|
+
public function testRenderObjectRefWithRefMethod()
|
247
|
+
{
|
248
|
+
$object = new ObjectRefWithRefAndId;
|
249
|
+
$result = Runtime::getObjectRefName($object);
|
250
|
+
$this->assertSame('customRef', $result);
|
251
|
+
|
252
|
+
$result = Runtime::renderObjectRefId($object);
|
253
|
+
$this->assertSame('custom_ref_>id', $result);
|
254
|
+
}
|
255
|
+
|
256
|
+
/** @dataProvider getRuntimeTests */
|
257
|
+
public function testRuntime($file)
|
258
|
+
{
|
259
|
+
$parts = $this->parseTestFile($file);
|
260
|
+
|
261
|
+
file_put_contents($file . '.haml', $parts['HAML']);
|
262
|
+
file_put_contents($file . '.php', $parts['FILE']);
|
263
|
+
file_put_contents($file . '.exp', $parts['EXPECT']);
|
264
|
+
|
265
|
+
try {
|
266
|
+
ob_start();
|
267
|
+
require $file . '.php';
|
268
|
+
$out = ob_get_clean();
|
269
|
+
} catch (\Exception $e) {
|
270
|
+
$this->assertException($parts, $e);
|
271
|
+
$this->cleanup($file);
|
272
|
+
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
$this->assertException($parts);
|
276
|
+
|
277
|
+
file_put_contents($file . '.out', $out);
|
278
|
+
|
279
|
+
$this->assertSame($parts['EXPECT'], $out);
|
280
|
+
|
281
|
+
$this->cleanup($file);
|
282
|
+
}
|
283
|
+
|
284
|
+
protected function cleanup($file)
|
285
|
+
{
|
286
|
+
if (file_exists($file . '.out')) {
|
287
|
+
unlink($file . '.out');
|
288
|
+
}
|
289
|
+
unlink($file . '.haml');
|
290
|
+
unlink($file . '.php');
|
291
|
+
unlink($file . '.exp');
|
292
|
+
}
|
293
|
+
|
294
|
+
public function getRuntimeTests()
|
295
|
+
{
|
296
|
+
if (false !== $tests = getenv('ENV_TESTS')) {
|
297
|
+
$files = explode(' ', $tests);
|
298
|
+
} else {
|
299
|
+
$files = glob(__DIR__ . '/fixtures/runtime/*.test');
|
300
|
+
}
|
301
|
+
|
302
|
+
return array_map(function ($file) {
|
303
|
+
return array($file);
|
304
|
+
}, $files);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
class ObjectRefWithGetIdAndId
|
309
|
+
{
|
310
|
+
public $getId = '>get_id';
|
311
|
+
public $id = '>id';
|
312
|
+
|
313
|
+
public function getId()
|
314
|
+
{
|
315
|
+
return $this->getId;
|
316
|
+
}
|
317
|
+
|
318
|
+
public function id()
|
319
|
+
{
|
320
|
+
return $this->id;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
class ObjectRefWithId
|
325
|
+
{
|
326
|
+
public function id()
|
327
|
+
{
|
328
|
+
return '>id';
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
class ObjectRefWithRefAndId extends ObjectRefWithId
|
333
|
+
{
|
334
|
+
public function hamlObjectRef()
|
335
|
+
{
|
336
|
+
return 'customRef';
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
class ObjectRefWithoutId
|
341
|
+
{
|
342
|
+
protected function id()
|
343
|
+
{
|
344
|
+
return '>id';
|
345
|
+
}
|
346
|
+
}
|
347
|
+
}
|
348
|
+
namespace {
|
349
|
+
class Foo_Bar {}
|
350
|
+
class FooBar {}
|
351
|
+
class FooBBar {}
|
352
|
+
}
|
353
|
+
|
354
|
+
namespace Foo\Bar {
|
355
|
+
class BazQux {}
|
356
|
+
}
|