私は、Drupal 8のhtml.twigファイルに単純なデータ配列があることを期待してループしています。下のブロックをページに追加すると、Drupalは "予期しないエラー "となる。そして今のところ、これはページに静的なことは大丈夫です。Drupalのループスルー小枝
注:私はDrupalとtwigに1週間足らずで、私のPHPは10年錆びています。
{%
set top_customers = {
{ name: "Altera G", logo: "logo-alterg.png", }
{ name: "Hollywood Was Museum", logo: "logo-hollywoodwaxmuseum.png", }
{ name: "iroaHealth", logo: "logo-iorahealth.png", }
{ name: "Lionel", logo: "logo-lionel.png", }
{ name: "Mashable", logo: "logo-mashable.png", }
{ name: "People Fluent", logo: "logo-peoplefluent.png", }
{ name: "Shop Kick", logo: "logo-shopkick.png", }
{ name: "Wistia", logo: "logo-wistia.png", }
}
%}
{{ dump(top_customers) }}
<section class="row cta-section row-padding-130">
<div class="row-inner site-width">
<div class="brick-10 center-brick">
<h3>These brands are changing the way they think about AP by using MineralTree</h3>
</div>
<div class="brick-12 center-brick">
<ul class="logo-list margin-top-78 clearfix">
{% for customer in top_customers %}
<li>
<img class="customer-logo img-fluid" src="{{ directory }}/images/customer-logos/{{ customer.logo }}" alt="{{ customer.name }}" />
</li>
{% endfor %}
</ul>
</div>
<div class="brick-6 center-brick">
<div class="margin-top-78">
<a href="/about-us/our-customers.html" class="solid-cta-btn button-large">view all our customers</a>
</div>
</div>
</div>
</section>
ありがとうございました!
あなたがそのエラーをもう持っていますか?私たちがどこを見るか分からなければ、始めるのは難しいです。 – nerdlyist
「Twig_Error_Syntax:ハッシュキーは、引用符付きの文字列、数字、名前、またはかっこで囲まれた式でなければなりません( "themes/custom/mineraltree/templates"の値 "{"の予期しないトークン "punctuation" Twig_ExpressionParser-> parseHashExpression()(/Applications/MAMP/htdocs/mineraltree/vendor/twig/twig/lib/Twig/ExpressionParser.phpの281行目)の4行目の "/region--banner5.html.twig"を参照してください。 – MWA