Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mustache specs - whitespace compliance #303

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

danielfagerstrom
Copy link
Contributor

Fixed the failing whitespace tests from the Mustache spec from my Mustache spec pull request.

  1. Spaces from standalone tags without newline should be stripped.
  2. Partial tags SHOULD be treated as standalone when appropriate. If this tag
    is used standalone, any whitespace preceding the tag should treated as
    indentation, and prepended to each line of the partial before rendering. specs

To implement the second point I introduced a whitespace variable in the parse function to keep track on whitespace on the same row before a standalone tag. For partials the content of the whitespace variables is stored in the parse tree and used for compiling an indented version of the partial during rendering. To keep track on instances of the same partial with different of indentation in the partial cache I prefixed the partial name with the indentation in the cache. Also needed to store non compiled partials and introduced indentation arguments for getPartial and compilePartial.

The implementation borrowed from Milk.

… a standalone template should be indented before it is applied on view data rather than after as in the previous commit. To accomplish this I added a cache for keeping the partial templates, not just the complied result and added an 'indentation' argument to getPartial and compilePartial.
@mjackson
Copy link
Collaborator

mjackson commented Apr 4, 2013

@danielfagerstrom Would you please rework this pull request to include only the commits that have to do with whitespace compliance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants