Monday, 22 May 2017

Creating nested spans in Pug

I am trying to get my schema correct for an event. I have the following pug/jade code. The problem is that the location span closes at the end of the if statement and my itemprop='name' span is outside location and it is not valid by google:

if event.location.suburb
                            span(itemprop='location', itemscope, itemtype='http://schema.org/Place')
                                span(itemprop="address" itemscope itemtype="http://schema.org/PostalAddress")
                                    span(itemprop='addressLocality')= event.location.suburb
                                    | , 
                                    span(itemprop='addressRegion')= event.location.state
                        if event.listing
                                span.hidden-xs-discreet
                                |  organised by 
                                a(href=event.listing.url,itemprop='name') #{event.listing.key}

Renders as

<span itemprop="location" itemscope="itemscope" itemtype="http://schema.org/Place">
<span itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">Uki</span>, 
<span itemprop="addressRegion">New South Wales</span>
</span></span>
<span class="hidden-xs-discreet"> organised by <a href="/event-organiser/yoga-events-australia">yoga-events-australia</a></span>



via Alex Grant

No comments:

Post a Comment