Search code examples
node.jsmarkuppug

Jade: Links inside a paragraph


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.

Solution

  • 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]]