Nate
Nate

Reputation: 95

How do you run scripts in Jade template sub blocks?

I'm using Jade and I have a template and a content block. I can run scripts in the template but how do I run the scripts in the content block?

Here's a bare bones example, mintemplate.jade:

doctype html
html
head
    script.
        alert('Layout Ready!');
body
    h1 Test
        block content

and test.jade:

extends minlayout
script.
    alert('Content Ready!');

block content
    h2 Content

The 'Layout Ready' alert works fine but the 'Content Ready' alert never appears.

Upvotes: 0

Views: 459

Answers (1)

invernomuto
invernomuto

Reputation: 10211

you need to move script declaration under block definition

extends minlayout

block content

    script.

        alert('Content Ready!');

    h2 Content

Template Inheritance

Upvotes: 3

Related Questions