Skip to content

add support for -%> - #4

Open
bolasblack wants to merge 1 commit into
weavejester:masterfrom
bolasblack:support-ignore-next-line-break
Open

add support for -%>#4
bolasblack wants to merge 1 commit into
weavejester:masterfrom
bolasblack:support-ignore-next-line-break

Conversation

@bolasblack

Copy link
Copy Markdown

No description provided.

Comment thread src/comb/template.clj
([s]
(print "(print " (pr-str s) ")"))
([s emit-next-line-break?]
(if emit-next-line-break?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a better way of doing this. We can change the regular expression instead:

(def delimiters ["<%" "%>"])
(def trimmer    "-")
 
(def parser-regex
  (let [[s e] delimiters, t trimmer]
    (re-pattern
     (str "(?s)\\A"
          "(?:" "(.*?)"
          "(?:" "\\s*" s t "|" s ")"
          "(.*?)"
          "(?:" t e "\\s*" "|" e ")"
          ")?"
          "(.*)\\z"))))

So we match \s*<%- or <% at the beginning, and -%>\s* or %> at the end. This also allows for trimming whitespace at the beginning.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but we need to decide how to deal with <%=- %>, ignore - or print result and trimming whitespace?

@weavejester weavejester Feb 20, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think ERB supports <%=-, or rather, it evaluates to treating the - as a subtraction. <%-= doesn't work in ERB either, though I don't see why it shouldn't. In Comb we might as well support it, and the regex above should do that fine.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants