如何解决PHP Fat Free 框架 - 模板渲染不正确
我假设我有一个开放的 HTML 标签或其他东西,但在我的生活中我无法弄清楚这个。
<div data-page-title="Let's add some people" data-floating-order>
<p>We need details for each person on your policy. Make sure you have names and dates of birth ready.</p>
</div>
<div data-page-title="Who is applying?" data-floating-order>
<!--In the render this is breaking-->
<include href="views/components/radioNoLabel"
with="
groupClass='yesNo businessRadioGroup',label1=Business,value1=business,label2=Individual,value2=individual,name=business_or_person,class=business_or_person,defaultValue=business,selected={{@existingInputs.business_or_person}}"
/>
</div>
<!--Everything below here should not be relevant but yet it is-->
<check if="{{@existingInputs.person_name}}">
<true>
<repeat group="{{@existingInputs.person_name}}" value="{{@person}}" key="{{ @key }}" >
<include href="views/directorFormFields.tpl.htm"
with="person_name={{@existingInputs['person_name'][@key]}},date_of_birth={{@existingInputs['date_of_birth'][@key]}},gender={{@existingInputs['gender'][@key]}},employee_type={{@existingInputs['employee_type'][@key]}},waiting_period={{@existingInputs['waiting_period'][@key]}},benefit_period={{@existingInputs['benefit_period'][@key]}},scope_of_cover={{@existingInputs['scope_of_cover'][@key]}},personal_accident_limit_id={{@existingInputs['personal_accident_limit_id'][@key]}},personal_accident_injury_limit_id={{@existingInputs['personal_accident_injury_limit_id'][@key]}},cover_type={{@existingInputs['cover_type'][@key]}},is_sickness_added={{@existingInputs['is_sickness_added'][@key]}}
" />
</repeat>
</true>
<false>
<include href="views/directorFormFields.tpl.htm" />
</false>
我在渲染的模板临时文件 Syntax error,unexpected 'else' (T_ELSE),expecting end of file
<div data-page-title="Let's add some people" data-floating-order>
<p>We need details for each person on your policy. Make sure you have names and dates of birth ready.</p>
</div>
<div data-page-title="Who is applying?" data-floating-order>
<?PHP if ($existingInputs['person_name']) echo $this->render('views/components/radioNoLabel',NULL,['groupClass'=>'yesNo businessRadioGroup','label1'=>'Business','value1'=>'business','label2'=>'Individual','value2'=>'individual','name'=>'business_or_person','class'=>'business_or_person','defaultValue'=>'business','selected'=>$existingInputs['business_or_person']]+get_defined_vars(),0); ?>
<?PHP foreach (($existingInputs['person_name']?:[]) as $key=>$person): ?>
<?PHP echo $this->render('views/directorFormFields.tpl.htm',['person_name'=>$existingInputs['person_name'][$key],'date_of_birth'=>$existingInputs['date_of_birth'][$key],'gender'=>$existingInputs['gender'][$key],'employee_type'=>$existingInputs['employee_type'][$key],'waiting_period'=>$existingInputs['waiting_period'][$key],'benefit_period'=>$existingInputs['benefit_period'][$key],'scope_of_cover'=>$existingInputs['scope_of_cover'][$key],'personal_accident_limit_id'=>$existingInputs['personal_accident_limit_id'][$key],'personal_accident_injury_limit_id'=>$existingInputs['personal_accident_injury_limit_id'][$key],'cover_type'=>$existingInputs['cover_type'][$key],'is_sickness_added'=>$existingInputs['is_sickness_added'][$key]]+get_defined_vars(),0); ?>
<?PHP endforeach; ?>
<?PHP else: //This is the "unexpected else" ?>
<?PHP echo $this->render('views/directorFormFields.tpl.htm',get_defined_vars(),0); ?>
我需要注意的是,在“谁正在应用 div 被打开”之后,解析的模板会立即执行检查 if ($existingInputs['person_name']) echo
,直到该 div 关闭后才应进行该检查。>
radioNoLabel
模板包含:
<div class="radioGroup {{@groupClass}}">
<check if="{{@defaultValue && !@selected}}">
<true>
<set selected="{{@defaultValue}}" />
</true>
</check>
<check if="{{@selected == @value1}}">
<set label1class="active" />
</check>
<label class="{{@label1class}}">
<span>{{@label1}}</span>
<span>
<check if="{{@selected == @value1}}">
<true><input type="radio" checked="checked" class="{{@class}}" value="{{@value1}}" name="{{@name}}"/></true>
<false><input type="radio" class="{{@class}}" value="{{@value1}}" name="{{@name}}"/></false>
</check>
</span>
</label>
<check if="{{@selected == @value2}}">
<set label2class="active" />
</check>
<label class="{{@label2class}}">
<span>{{@label2}}</span>
<span>
<check if="{{@selected == @value2}}">
<true><input type="radio" checked="checked" class="{{@class}}" value="{{@value2}}" name="{{@name}}"/></true>
<false><input type="radio" class="{{@class}}" value="{{@value2}}" name="{{@name}}"/></false>
</check>
</span>
</label>
</div>
如果在其他地方使用,则输出 HTML
<div class="radioGroup yesNo businessRadioGroup">
<label class="">
<span>Business</span>
<span>
<input type="radio" class="business_or_person" value="business" name="business_or_person"/>
</span>
</label>
<label class="active">
<span>Individual</span>
<span>
<input type="radio" checked="checked" class="business_or_person" value="individual" name="business_or_person"/>
</span>
</label>
</div>
很奇怪,如果我将 Let's add some people
div 放在 who is applying?
div 下方,页面呈现没有错误,但标记不正确并将两个 div 连接在一起。
<div data-page-title="Who is applying?" data-floating-order="asd">
<div class="radioGroup yesNo businessRadioGroup">
<label class="">
<span>Business</span>
<span>
<input type="radio" class="business_or_person" value="business" name="business_or_person"/>
</span>
</label>
<label class="active">
<span>Individual</span>
<span>
<input type="radio" checked="checked" class="business_or_person" value="individual" name="business_or_person"/>
</span>
</label>
</div>
<p>We need details for each person on your policy. Make sure you have names and dates of birth ready.</p>
</div>
如果我包含 radioNoLabel 的原始 HTML 输出而不是 <include>
标记,则一切正常。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。