I'm struggling to pass some text into my child component via the parent. Does anyone have any suggestions on how I might do this?
Here's my parent:
<% include ../partials/hero %>
Heres my child:
<div class="hero">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 g-no-padding">
<div class="cont">
<img class="hero--img" src="../img/hero.jpg">
<h1 class="hero--title g-title--big g-font--white">TEXT PASSED FROM PARENT</h1>
</div>
</div>
</div>
</div>
</div>
I've tried using:
<% var data= 'blah blah blah'; %>
...and tried calling using :
<%= data %>
...but it only threw errors for me. Any help or advice is appreciated.
From the EJS documentation :
EJS does not specifically support blocks, but layouts can be implemented by including headers and footers, like so:
<%- include('header') -%>
<h1>
Title
</h1>
<p>
My page
</p>
<%- include('footer') -%>
TL;DR You cannot pass content to includes in EJS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.