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

Support inline tags #1323

Merged
merged 1 commit into from
Dec 11, 2013
Merged

Support inline tags #1323

merged 1 commit into from
Dec 11, 2013

Conversation

ForbesLindesay
Copy link
Member

[closes #936]

This is the biggest roadblock in the way of a 1.0.0 release. I'm not entirely happy with the implementation, but I think it's 90% of the way there, would love to get input from people.

@vendethiel
Copy link
Contributor

Can you tell me what does this give ?

p #[b #{var}]

@ForbesLindesay
Copy link
Member Author

That gives me "unexpected token var because `var is a keyword in javascript, but:

p #[b #{5+6}]

Gives

<p><b>11</b></p>

and

p #[b #{variable}]

gives

<p><b></b></p>

and the JavaScript for that template is:

function template(locals) {
  var buf = [];
  var locals_ = (locals || {}),
      variable = locals_.variable;
  buf.push("<p><b>"
          + (jade.escape((jade.interp = variable) == null ? '' : jade.interp))
          + "</b></p>");
  return buf.join("");
}

So you can definitely pass in a variable value as expected.

@vendethiel
Copy link
Contributor

I meant "var" in a "whatever js literal" way ;). Good ! Glad to see this !

ForbesLindesay added a commit that referenced this pull request Dec 11, 2013
@ForbesLindesay ForbesLindesay merged commit 9105cdd into master Dec 11, 2013
@ForbesLindesay ForbesLindesay deleted the inline-tags branch December 11, 2013 14:22
@igor10k
Copy link

igor10k commented Dec 29, 2013

I wonder how to print actual [ and ] characters within inline tags? The easiest way I can think of is

p Some #[a(href="#") link with #{'['} and #{']'} character]

@ForbesLindesay
Copy link
Member Author

Yeh, I didn't really think this through that well. I think I'll have to come up withs something a bit more clever for detecting the end of the inline tag. It also doesn't work if you have an un-matched ' or ".

@caneta
Copy link

caneta commented Feb 10, 2017

This is really nice and works well, but I cannot find it in the documentation...

@TimothyGu
Copy link
Member

@caneta, it is filed under interpolation

@caneta
Copy link

caneta commented Feb 13, 2017

I see...thanks @TimothyGu

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.

Feature Request: Nesting Syntax
5 participants