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

Only named blocks and mixins can appear at the top level of an extending template #2658

Closed
StephanyBatista opened this issue Jan 4, 2017 · 8 comments

Comments

@StephanyBatista
Copy link

StephanyBatista commented Jan 4, 2017

layout.pug

doctype html
html
  head
    title Admin
    meta(http-equiv='Content-Type', content='text/html; charset=utf-8')
    meta(name='viewport', content='width=device-width, initial-scale=1.0')
    link(href='/lib/bootstrap/dist/css/bootstrap.min.css', rel='stylesheet')
    link(href='/css/bootstrap-overrides.css', type='text/css', rel='stylesheet')
    link(rel='stylesheet', type='text/css', href='/css/layout.css')
    link(rel='stylesheet', type='text/css', href='/css/elements.css')
    link(rel='stylesheet', type='text/css', href='/css/icons.css')
    link(rel='stylesheet', type='text/css', href='/css/jquery-ui-1.10.2.custom.css')
    link(rel='stylesheet', type='text/css', href='/lib/components-font-awesome/css/font-awesome.min.css')
    link(rel='stylesheet', type='text/css', href='/css/index.css', media='screen')
    link(href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800', rel='stylesheet', type='text/css')
    link(href='http://fonts.googleapis.com/css?family=Lato:300,400,700,900,300italic,400italic,700italic,900italic', rel='stylesheet', type='text/css')
    //if lt IE 9
        script(src='http://html5shim.googlecode.com/svn/trunk/html5.js')
  body
    header.navbar.navbar-inverse(role='banner')
      .navbar-header
        a.navbar-brand(href='index.html')
          img(src='/img/logo.png', alt='logo')
      ul.nav.navbar-nav.pull-right.hidden-xs
        li.dropdown
          a.dropdown-toggle.hidden-xs.hidden-sm(href='#')
            | Your account
            b.caret
    #sidebar-nav
      ul#dashboard-menu
        li.active
          .pointer
            .arrow
            .arrow_border
          a(href='index.html')
            i.fa.fa-home
            span Home
        li
          a.dropdown-toggle(href='#')
            i.fa.fa-users
            span Usuarios
            span.glyphicon.glyphicon-chevron-down
          ul.submenu
            li
              a(href='user-list.html') User list
            li
              a(href='new-user.html') New user form
    .content
        block content
    script(src='http://code.jquery.com/jquery-latest.js')
    script(src='/lib/bootstrap/dist/js/bootstrap.min.js')
    script(src='/js/jquery-ui-1.10.2.custom.min.js')
    script(src='/lib/jquery-knob/dist/jquery.knob.min.js')
    script(src='/js/jquery.flot.js')
    script(src='/js/jquery.flot.stack.js')
    script(src='/js/jquery.flot.resize.js')
    script(src='/js/theme.js')    

user/create..pug

extends ../layout.pug
block content
#pad-wrapper.new-user
.row.header
    .col-md-12
    h3 Create a new user
.row.form-wrapper
    .col-md-9.with-sidebar
    form.form-horizontal(role='form')
        .form-group
        label.col-md-2.control-label(for='inputName1') Name
        .col-md-8
            input#inputName1.form-control(type='text', placeholder='Name')
        .form-group
        label.col-md-2.control-label(for='inputEmail1') Email
        .col-md-8
            input#inputEmail1.form-control(type='text', placeholder='Email')
        .form-group
        label.col-md-2.control-label(for='inputPhone1') Phone
        .col-md-8
            input#inputPhone1.form-control(type='text', placeholder='Phone')
        .form-group
        label.col-md-2.control-label(for='inputWebsite1') Website
        .col-md-8
            input#inputWebsite1.form-control(type='text', placeholder='Website')
        .form-group
        label.col-md-2.control-label(for='inputAddress1') Address
        .col-md-8
            input#inputAddress1.form-control(type='text', placeholder='Address')
        .form-group
        label.col-md-2.control-label(for='inputContent1') Content
        .col-md-8
            textarea#inputContent1.form-control(placeholder='Content', rows='5')
        .form-group
        .col-md-offset-2.col-md-8
            button.btn.btn-default(type='submit') Sign in
@ForbesLindesay
Copy link
Member

The content you (presumably) intended to put inside block content must be indented.

@KSXGitHub
Copy link

@ForbesLindesay

The content you (presumably) intended to put inside block content must be indented.

I encounter the same issue and your comment isn't vary clear to me.

@atrodriguez88
Copy link

I have the same problem

@ForbesLindesay
Copy link
Member

If your template has extends in it, it can only have other content inside blocks. i.e.

GOOD:

extends ./layout.pug

block content
  div some content

BAD:

extends ./layout.pug

block content
div this content isn't inside a block

@JhonnyJason
Copy link

JhonnyJason commented Sep 28, 2017

Notice also comments produce this error ^^

extents /parent.pug
block something
    somethingwithin

//and a nice comment for the next block
block commentedblock
    somethingwithincommentedblock

To work needs to be this :-)

extents /parent.pug
block something
    somethingwithin

   //and a nice comment for the next block
block commentedblock
    somethingwithincommentedblock

@dennyard
Copy link

it works for me. thanks

@KSXGitHub
Copy link

@JhonnyJason use this instead (////-)

extents /parent.pug
block something
    somethingwithin

//- and a nice comment for the next block
block commentedblock
    somethingwithincommentedblock

@eylemyildiz
Copy link

eylemyildiz commented May 22, 2020

Thanks @JhonnyJason for your comment :)
It works for me.

@pugjs pugjs locked as resolved and limited conversation to collaborators May 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants