ariatemplates / hashspace

JavaScript client-side template engine
http://hashspace.ariatemplates.com
Apache License 2.0
14 stars 18 forks source link

HTML syntax part 3 #323

Closed jakub-g closed 9 years ago

jakub-g commented 9 years ago

This is still WIP but I'm opening a PR already, since it's huge, so that someone can start reviewing (I'll add new commit with some tests, the src should be untouched or barely touched)

Almost all 200 files changed are just syntax update in HSP files. In some of the test files I had to tweak error messages since the way parser works has changed.


In first commit the two most interesting changes are hspblocks.pegjs and syntaxTree.js

Due to the way how HTML attributes are parsed, I had to change some tests (template8 once again for instance)

In hspblocks, crazily big amount of code is for error handling to have friendly messages instead of terse parse errors. For that I modified the HTMLAttribute to be more readable and provide code which is propagated to the template in case of template opening statement parse error.

In the last commit I added the suberrors-awareness to the playground, this meant having to modify log to output messages array apart from message string, so that I can format them the way I want (i.e. <br>-separated), because currently in hashspace it's impossible to easily do any kind of pre-display manipulation like e.g. introducing HTML newlines in a multiline string I kept message too (which just joins lines with a space) for backward compat (there were some failing log tests, I didn'qt want to touch it) In the JS generator code I took advantage of the fact that log methods can have varags input.

Notable missing parts:

jakub-g commented 9 years ago

Naturally I recommend using GH code review assistant to handle the hugeness of the PR ;)

divdavem commented 9 years ago

@jakub-g For info, I have done a rebase of your branch on the most recent commits from https://github.com/ariatemplates/hashspace, resolving some conflicts. Here is the resulting branch on my fork: https://github.com/divdavem/hashspace/tree/jakub-htmlsyntax-part3

jakub-g commented 9 years ago

I've added a number of tests in the last commit. There are still some missing features to be added (listed them in the first message of this PR) but this PR is big enough already - they can be added later on.

Anyone brave enough to review this monster? :)

One obvious downside of this PR I can already tell is that TemplateStart in hspblocks got really huge. Probably for debugging sake, it could be better to move this code to the later stage so you could run it with node-inspector and put breakpoints etc. OTOH it turned out it was pretty convenient for me to use http://pegjs.majda.cz/online for real-time evaluation of parse tree.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.1%) when pulling c974ff81d3e1853dbfe22792843f548d031eb86f on jakub-g:htmlsyntax-part3 into 897c7ebc744058847f9a37c9b767ef4057b275a1 on ariatemplates:master.

marclaval commented 9 years ago

LGTM

jakub-g commented 9 years ago

@mlaval thanks for review @divdavem thanks for rebasing and resolving conflicts :)