Export to GitHub

json-template - issue #2

Add whitespace options


Posted on Mar 8, 2009 by Helpful Rhino
  • For compressing all whitespace
  • For preserving indentation
  • default: do nothing

Comment #1

Posted on Apr 10, 2009 by Quick Hippo

Proposed behavior:

whitespace-mode: any

The template author does not care, this is for backward compatibility with the existing somewhat arbitrary behavior. The existing tests may be relaxed to do ignore_whitespace=True

whitespace-mode: strip

remove whitespace around directives (for network efficiency, yes it matters)

whitespace-mode: preserve

Do exactly what the template says. (The current behavior is almost exactly)

whitespace-mode: smart-indent

Well indented templates should produce well-indented outputs. Useful for generating both HTML/XML and source code.

Comment #2

Posted on Apr 17, 2009 by Quick Hippo

The "smart indent" style was done for the Python version. I have written some notes on the Reference wiki page that makes it clear that it's optional.

For the JavaScript version, I want to keep the code size small, and this "smartness" does add a bit of code size. So we could leave it, or find a more compact way to implement it -- maybe with a tokenizing regex that does something like (block directive)|(substitution) to distinguish the 2 cases.

Comment #3

Posted on Apr 17, 2009 by Quick Hippo

(No comment was entered for this change.)

Status: Started

Labels:
Type-Enhancement Priority-Medium