Jade: Links inside a paragraph


Question

I'm trying to author a few paragraphs with Jade, but finding it difficult when there are links inside a paragraph.

The best I can come up with, and I'm wondering if there's a way to do it with less markup:

p
  span.
   this is the start
   of the para.
  a(href="http://example.com") a link
  span.
    and this is the rest of
    the paragraph.
1
115
8/8/2011 11:05:18 PM

Accepted Answer

As of jade 1.0 there's an easier way to deal with this, unfortunately I can't find it anywhere in the official documentation.

You can add inline elements with the following syntax:

#[a.someClass A Link!]

So, an example without going into multiple lines in a p, would be something like:

p: #[span this is the start of the para] #[a(href="http://example.com") a link] #[span and this is the rest of the paragraph]

You can also do nested inline elements:

p: This is a #[a(href="#") link with a nested #[span element]]
113
5/29/2014 12:21:51 AM

You can use a markdown filter and use markdown (and allowed HTML) to write your paragraph.

:markdown
  this is the start of the para.
  [a link](http://example.com)
  and this is the rest of the paragraph.

Alternatively it seems like you can simply ouput HTML without any problems:

p
  | this is the start of the para.
  | <a href="http://example.com">a link</a>
  | and this is he rest of the paragraph

I wasn't aware of this myself and just tested it using the jade command line tool. It seems to work just fine.

EDIT: It seems it can actually be done entirely in Jade as follows:

p
  | this is the start of the para  
  a(href='http://example.com;) a link
  |  and this is the rest of the paragraph

Don't forget an extra space at the end of para (although you can't see it. and between | and. Otherwise it will look like this para.a linkand not para a link and


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon