我正在创建一个用于组织活动的网络应用程序,我想将其显示为网格和div列表。在我的代码中,我导入了两个jade文件,以便将它们用作mixin。这是"主要"玉:
include blockEventView
include gridEventView
-var events = user.createdEvents
.container#myEvents.hide
.card
.lv-header-alt.clearfix.m-b-5
if(events != null)
h2.lvh-label.hidden-xs #{events.length} Events
else
h2.lvh-label.hidden-xs 0 Events
mixin blockEventView(events)
mixin gridEventView(events,"my-event-grid")
blockEventView.jade
mixin blockEventView(events)
.card-body.card-padding
if events != null
.row
each event in events
.col-sm-4.col-xs-6
.card.event(data-id = event._id)
.card-header
h2 #{event.title}
h2.text-rigth
span #{events.length}
if event.participants.length > 1
i.zmdi.zmdi-accounts.zmdi-hc-fw
else
i.zmdi.zmdi-account.zmdi-hc-fw
if event.creator
small by #{event.creator}
else
small by anonimous
.card-body.card-padding
if event.description
p #{event.description}
else
p no description avariable
else
h3 No Events
gridEventView.jade
mixin gridEventView(events,id)
.table-responsive
table(id= #{id}).table.table-striped
thead
tr
th(data-column-id='id', data-identifier="true",data-visible="false")
th(data-column-id='title', data-identifier="false") title
th(data-column-id="creator") By
th(data-column-id="participants") Participants
tbody
这是我从服务器得到的错误:
{ [SyntaxError: /Users/VeaVictis/Project/Organizator/app/views/myEvents.jade:2
1| include blockEventView
> 2| include gridEventView
3|
4| -var events = user.createdEvents
5|
Unexpected token ILLEGAL]
path: '/Users/VeaVictis/Project/Organizator/app/views/myEvents.jade' }
所以看起来我不能包含两个玉文件。一旦我删除第二个"包括"一切正常。我怎样才能实现我想要的功能?所以只是为了清洁,我正在寻找一个包含我的两个文件的视图,并将它们用作mixin。谢谢
答案 0 :(得分:0)
为什么在包含后定义了事件变量?试试看看会发生什么:
-var events = user.createdEvents
include blockEventView.jade
include gridEventView.jade