неожиданная ошибка «отступа» токена во время работы - PullRequest
0 голосов
/ 13 апреля 2020

layout.jade

doctype
html
    head
      title=title
      link(rel='stylesheet',href='/stylesheet/style.css')
    body
      block content 

index.jade

extend layout   

  block content 
      h1 Add new contact
      form(method="POST", action='/new_contact')
      p Name:
      input#title(type="text ",name=name)
      p Phone:
      input#title(type="text",name=phone)

      p: button(type="submit") Add new Contact
      h1 Add new database
      form(method="POST", action='/createdb')
      p Database name:
      input#title(type="text",name=dbname)
      p: button(type="submit") Add new Database

      h1 Delete the Contact
      form(method="POST", action='/delete_contact')
      p Phone:
      input#title(type="text",name=phone)
      p: button(type="submit") Delete Contact

      h1 View the Contact
      form(method="POST", action='/view_contact')
      p Phone:
      input#title(type="text",name=phone)
      p: button(type="submit") View the  Contact

Я постоянно получаю эту ошибку при запуске приложения

Error: C:\Users\Priyanka-PC\Desktop\Node\NodeApp\views\index.jade:3
    1|       extend layout
    2|       
  > 3|         block content 
    4|             h1 Add new contact
    5|             form(method="POST", action='/new_contact')
    6|             p Name:

unexpected token "indent"
    at Parser.parseExpr (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\parser.js:254:15)
    at Parser.parse (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\parser.js:122:25)
    at parse (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:104:21)
    at Object.exports.compile (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:205:16)
    at handleTemplateCache (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:174:25)
    at Object.exports.renderFile (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:380:10)
    at Object.exports.renderFile (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:370:21)
    at View.exports.__express [as engine] (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\jade\lib\index.js:417:11)
    at View.render (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\express\lib\view.js:135:8)
    at tryRender (C:\Users\Priyanka-PC\Desktop\Node\NodeApp\node_modules\express\lib\application.js:640:10)

Пожалуйста, помогите.

1 Ответ

1 голос
/ 14 апреля 2020

Две проблемы:

  1. Это extends не extend

  2. Ваш блок должен находиться на том же "уровне", что и extends

Это будет работать:

extends layout   

block content
  h2 blah blah blah

Пожалуйста, прочитайте документы на Наследование в pug для более подробной информации и некоторых примеров.

...