Mixin declared without body

一曲冷凌霜 提交于 2021-01-28 06:42:06

问题


I am doing the Wes-bos Learn node course.I am on the part of saving stores and using mixins. When I write mixins and run my app it gives this error.

Error: C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\views\mixins\_storeForm.pug:1:1
> 1| mixin storeForm(store = {})
   -------^
2| form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
3| label(for="name") name
4| input(type="text" name="name")

Mixin storeForm declared without body
at makeError (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-error\index.js:32:13)
at Parser.error (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:53:15)
at Parser.parseMixin (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:871:12)
at Parser.parseExpr (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:204:21)

This is the file in Mixins (_storeForm.pug)

mixin storeForm(store = {})
form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
  label(for="name") name
  input(type="text" name="name")

This is the file in views folder

extends layout

include mixins/_storeForm

block content 
  .inner
    h2= title 
    +storeForm({name:'dkjd'})

I am new to nodejs/pug/express. What is wrong with this code. This code in the given video works fine but not on my desktop.


回答1:


Inside your mixin storeForm, you need to indent form and its children once more. Like so:

mixin storeForm(store = {})
    form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
        label(for="name") name
        input(type="text" name="name")


来源:https://stackoverflow.com/questions/46528783/mixin-declared-without-body

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!