Skip to content

Instantly share code, notes, and snippets.

@lawrencewoodman
Created July 19, 2011 10:32
Show Gist options
  • Save lawrencewoodman/1091937 to your computer and use it in GitHub Desktop.
Save lawrencewoodman/1091937 to your computer and use it in GitHub Desktop.
An example template for a Service review marked-up with microdata using the http://schema.org vocabularies
<div class="panelTab">Business / Service</div>
<div class="panel">
{% if page.categories contains "restaurant" %}
<div itemscope itemtype="http://schema.org/Restaurant" itemref="reviews">
{% elsif page.categories contains "hotel" %}
<div itemscope itemtype="http://schema.org/Hotel" itemref="reviews">
{% else %}
<div itemscope itemtype="http://schema.org/Organization" itemref="reviews">
{% endif %}
<ul class="reviews">
<li id="businessName" itemprop="name">{{ page.business-name }}</li>
<li itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
{{ page.avg-rating|star_rating }}
{% if page.display-map %}
&nbsp;
{% else %}
<br />
{% endif %}
<span itemprop="ratingValue" style="display:none">{{ page.avg-rating }}</span>
<span itemprop="reviewCount">{{ page.num-reviews }}</span>
{% if page.num-reviews == 1 %}
Review
{% else %}
Reviews
{% endif %}
</li>
<span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
{% if page.address-po-box %}
<li id="address-po-box" itemprop="postOfficeBoxNumber">{{ page.address-po-box }}</li>
{% endif %}
{% if page.street-address %}
<li id="street-address" itemprop="streetAddress">{{ page.street-address }}</li>
{% endif %}
{% if page.address-locality %}
<li id="address-locality" itemprop="addressLocality">{{ page.address-locality }}</li>
{% endif %}
{% if page.address-region %}
<li id="address-region" itemprop="addressRegion">{{ page.address-region }}</li>
{% endif %}
{% if page.address %}
<li id="address" itemprop="streetAddress">{{ page.address | replace: ',', '<br />'}}</li>
{% endif %}
<li id="postal-code" itemprop="postalCode">{{ page.postal-code | upcase}}</li>
{% if page.country %}
{% comment %}Need to create a filter to turn a country name into a ISO 3166-1 alpha-2 country code{% endcomment %}
<li id="country" itemprop="addressCountry">{{ page.country}}</li>
{% endif %}
</span>
{% if page.tel-number %}
<li id="tel-number">Tel: <span itemprop="telephone">{{ page.tel-number }}</span></li>
{% endif %}
{% if page.website %}
<li id="website"><a itemprop="url" href="http://{{ page.website }}">{{ page.website|truncate: 30 }}</a></li>
{% endif %}
</ul>
</div>
<div class="panelTab">Reviews</div>
<div class="panel" id="reviews">
{% for review in page.reviews reversed %}
<div itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<span class="review-date">
<time itemprop="datePublished" datetime="{{review.date|iso8601}}">
{{ review.date }}
</time>
</span>
<span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
<meta itemprop="ratingValue" content="{{review.rating}}" />
{{ review.rating|star_rating }}
</span>
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
{% if review.reviewer-url %}
<a class="reviewer" href="http://{{ review.reviewer-url }}" itemprop="url">
<span itemprop="name">{{ review.reviewer }}</span>
</a>
{% else %}
<span class="reviewer" itemprop="name">{{ review.reviewer }}</span>
{% endif %}
</span>
<div class="comment">
<span itemprop="reviewBody">
{{ review.comment |newline_to_br }}<br />
</span>
</div>
</div>
{% endfor %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment