Skip to content

Commit

Permalink
Twig syntax cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustMiller committed Feb 5, 2024
1 parent f8438ec commit c731e2b
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions templates/_/components/blocks/ctaCaption.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{% if heading %}
<span class="caption-heading">
{{ include(template_from_string(heading)|raw) }}
{{ include(template_from_string(heading) | raw) }}
</span>
{% endif %}

Expand All @@ -28,7 +28,7 @@

{% if information %}
<span class="information">
{{ include(template_from_string(information)|raw) | typogrify }}
{{ include(template_from_string(information) | raw) | typogrify }}
</span>
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions templates/_/components/blocks/form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<div id="{{ freeformId }}" class="content-block form-block {{ isFirst }}" data-scroll-section>

{{ theBlock.form.render() }}
{{ theBlock.form.render() }}

<template id="{{ templateId }}">
{{ theBlock.successMessage | default("Form submitted successfully!") | typogrify | raw }}
Expand All @@ -48,11 +48,11 @@
See: https://docs.solspace.com/craft/freeform/v3/templating/ajax-forms.html#customization
#}
<script>
document.getElementById('{{ freeformId }}').addEventListener('freeform-ready', function(event) {
document.getElementById("{{ freeformId | e('js') }}").addEventListener('freeform-ready', function(event) {
const freeform = event.target.freeform;
freeform.setOption('renderSuccess', function() {
const templateClone = document.getElementById('{{ templateId }}').content.cloneNode(true)
const templateClone = document.getElementById("{{ templateId | e('js') }}").content.cloneNode(true)
const successMessage = document.createElement("div");
successMessage.classList.add("ff-form-success");
Expand Down
4 changes: 2 additions & 2 deletions templates/_/components/blocks/heading.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{# @var craft \craft\web\twig\variables\CraftVariable #}

{% set heading = theBlock.heading ?? altText|default('') %}
{% set heading = theBlock.heading ?? altText | default('') %}
{% set isFirst = isFirst ?? false %}

{% if heading|length %}
{% if heading | length %}

<div class="content-block heading-block{{ isFirst ? ' isFirst' : '' }}" data-scroll-section>
<div class="heading">
Expand Down
2 changes: 1 addition & 1 deletion templates/_/components/blocks/imageAndHeadings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% set subHeading = theBlock.subHeading | default('') %}
{% set highlightText = theBlock.highlightText ? 'is-highlighted' : '' %}

{% set hasHeroImage = entry.heroImage|length ? true : false %}
{% set hasHeroImage = entry.heroImage | length ? true : false %}

<div class="content-block image-and-headings-block {{ isFirst }} {{ textColor }} {{ highlightText }}" data-scroll-section>

Expand Down
8 changes: 4 additions & 4 deletions templates/_/components/blocks/slider.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{# {% if exhibit %} #}

<div class="content-block slider-block {{ isFirst }} {% if slideImages|length %}is-image{% else %}is-entry{% endif %} {% if darkUI %}dark-ui{% endif %}" data-scroll-section>
<div class="content-block slider-block {{ isFirst }} {% if slideImages | length %}is-image{% else %}is-entry{% endif %} {% if darkUI %}dark-ui{% endif %}" data-scroll-section>

<div class="slider-info">

Expand All @@ -20,7 +20,7 @@
</a>
</div>

<h4 class="slider-heading {% if heading|length == 0 %}hide-on-tablet{% endif %}">
<h4 class="slider-heading {% if heading | length == 0 %}hide-on-tablet{% endif %}">
{{ heading }}
</h4>

Expand All @@ -30,7 +30,7 @@
{% include "_/svg/arrowLeft" %}
</button>

{% if slideEntries|length and slideImages|length == 0 %}
{% if slideEntries | length and slideImages | length == 0 %}
<span class="divider">|</span>
{% endif %}

Expand Down Expand Up @@ -97,7 +97,7 @@

{% set slideTitle = entry.title %}
{% set slideNewsCategory = entry.newsCategory.one() | default('') %}
{% set slideDate = entry.postDate|date('m.y') | default('') %}
{% set slideDate = entry.postDate | date('m.y') | default('') %}
{% set slideUrl = entry.url %}

{% if heroImage %}
Expand Down
6 changes: 3 additions & 3 deletions templates/_/components/blocks/statsAndImage.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# @var craft \craft\web\twig\variables\CraftVariable #}

{% set internalLink = theBlock.internalLink.one().url|default('') %}
{% set externalLink = theBlock.externalLink|default('') %}
{% set internalLink = theBlock.internalLink.one().url | default('') %}
{% set externalLink = theBlock.externalLink | default('') %}

{% set linkUrl = internalLink ? internalLink : externalLink %}

Expand All @@ -13,7 +13,7 @@

<div class="text-container">

<div class="stat-left {% if theBlock.rightStatValue|length == 0 %}hide-on-mobile{% endif %}">
<div class="stat-left {% if theBlock.rightStatValue | length == 0 %}hide-on-mobile{% endif %}">
<div class="stat-value">
{{ theBlock.leftStatValue }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/_/components/picture.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
data-srcset="{{ srcset }}"
sizes="{{ sizes }}"
alt="{{ alt }}"
style="object-position: {{ asset.focalPoint|first * 100 }}% {{ asset.focalPoint|last * 100 }}%;"
style="object-position: {{ asset.focalPoint | first * 100 }}% {{ asset.focalPoint | last * 100 }}%;"
/>

{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/_/layouts/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% header "Link: <#{baseUrl}>; rel=dns-prefetch;,<#{baseUrl}>; rel=preconnect; crossorigin;" %}
<!DOCTYPE html>

<html lang="{{ craft.app.language |slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<html lang="{{ craft.app.language | slice(0,2) }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">

<head>
<link rel="dns-prefetch" href="{{ baseUrl }}" crossorigin>
Expand Down Expand Up @@ -33,7 +33,7 @@
{% if env != "local" %}
{% set inline_css = block("inline_css") is defined ? block("inline_css") : "" %}
{% endif %}
{% if inline_css|trim is not empty %}
{% if inline_css | trim is not empty %}
<style>{{ inline_css | raw | replace({'/assets/dist/': alias('@assetBaseUrl/assets/dist/')}) }}</style>
{{ craft.twigpack.includeCssModule('/css/site.css', true) }}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion templates/_/pages/contact.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% extends "_/layouts/site" %}

{% block inline_css %}
{{ source ("_/#{entry.type.handle}-critical.min.css", ignore_missing = true) }}
{{ source("_/#{entry.type.handle}-critical.min.css", ignore_missing = true) }}
{% endblock %}

{% block content %}
Expand Down
18 changes: 9 additions & 9 deletions templates/_/pages/exhibit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{% block content %}

<article class="{% if contentBlocks|length == 0 %}no-blocks{% endif %}" data-router-view="exhibit" data-handle="{{ entry.type.handle }}">
<article class="{% if contentBlocks | length == 0 %}no-blocks{% endif %}" data-router-view="exhibit" data-handle="{{ entry.type.handle }}">

<div class="exhibit-container" data-scroll-section>

Expand All @@ -37,22 +37,22 @@

{% set imageCaption = heroImage.imageCaption | default('') %}

{% if imageCaption|length %}
{% if imageCaption | length %}
<div class="caption">
{{ imageCaption | typogrify }}
</div>
{% endif %}

{% set startDate = entry.postDate|date('m.y') | default('') %}
{% set endDate = entry.expiryDate|date('m.y') | default('') %}
{% set startDate = entry.postDate | date('m.y') | default('') %}
{% set endDate = entry.expiryDate | date('m.y') | default('') %}

{% if startDate|length %}
{% if startDate | length %}
<div class="dates">
{{ startDate }} &mdash; {{ endDate }}
</div>
{% endif %}

{% if imageCaption|length %}
{% if imageCaption | length %}
<div class="tickets">
{% apply typogrify %}
Tickets are purchased at the Museum
Expand All @@ -66,13 +66,13 @@

</div>

{% if contentBlocks|length %}
{% if contentBlocks | length %}

{% include "_/components/block-matrix" with {contentBlocks: contentBlocks} %}
{% include "_/components/block-matrix" with { contentBlocks: contentBlocks } %}

{% else %}

{% include "_/components/blocks/heading" with {altText: 'Coming soon…'|t} %}
{% include "_/components/blocks/heading" with { altText: 'Coming soon…' | t } %}

{% endif %}

Expand Down
8 changes: 4 additions & 4 deletions templates/_/pages/home.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% block content %}

{% set heading = entry.heading | default('') %}
{% set headingWords = heading | split(" ") %}
{% set headingWords = heading | split(' ') %}

<article data-router-view="home">

Expand Down Expand Up @@ -39,7 +39,7 @@

<div class="exhibitions-title-container">
<h6 class="title" data-scroll data-scroll-speed="" data-scroll-delay="">
{{ 'Featured Exhibits'|t|replace(' ', '<br>')|raw }}
{{ 'Featured Exhibits' | t | replace(' ', '<br>') | raw }}
</h6>
</div>

Expand All @@ -51,8 +51,8 @@

{% set exhibitUrl = exhibit.url %}
{% set exhibitTitle = exhibit.title %}
{% set exhibitStartDate = exhibit.postDate|date('m.y') | default('') %}
{% set exhibitEndDate = exhibit.expiryDate|date('m.y') | default('') %}
{% set exhibitStartDate = exhibit.postDate | date('m.y') | default('') %}
{% set exhibitEndDate = exhibit.expiryDate | date('m.y') | default('') %}
{% set exhibitHeroImage = exhibit.heroImage.one() %}

{% do exhibitHeroImage.setTransform({
Expand Down
6 changes: 3 additions & 3 deletions templates/_/pages/news-article.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{% block content %}

{% if entry.heroImage|length %}
{% if entry.heroImage | length %}
{% set heroImage = entry.heroImage.one() %}

{% do heroImage.setTransform({
Expand All @@ -23,9 +23,9 @@
<div class="news-article-container" data-scroll-section>

{% include '_/svg/arrowLeft' %}
<a class="link-back" href="{{ url('news') }}">{{ 'Back to News'|t }}</a>
<a class="link-back" href="{{ url('news') }}">{{ 'Back to News' | t }}</a>

<h5 class="hero-heading">{{ entry.title |typogrify }}</h5>
<h5 class="hero-heading">{{ entry.title | typogrify }}</h5>

<img class="hero-image" src="{{ heroImage.url }}" alt="{{ heroImage.title }}">

Expand Down
12 changes: 6 additions & 6 deletions templates/_/pages/news.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

{% if category is defined %}
{% include '_/svg/arrowLeft' %}
<a class="link-back" href="{{ url('news') }}">{{ 'Back to News'|t }}</a>
<a class="link-back" href="{{ url('news') }}">{{ 'Back to News' | t }}</a>
{% endif %}

{% if category is defined %}
<div class="hero-category">{{ 'Category:'|t }}</div>
<div class="hero-category">{{ 'Category:' | t }}</div>
<h5 class="hero-category-heading">{{ category.title }}</h5>
{% else %}
<h1 class="hero-heading">{{ 'News'|t }}</h1>
<h1 class="hero-heading">{{ 'News' | t }}</h1>
{% endif %}

</div>
Expand Down Expand Up @@ -62,7 +62,7 @@

{% for newsEntry in pageEntries %}

{% set articleImage = newsEntry.heroImage|first %}
{% set articleImage = newsEntry.heroImage | first %}

{% do articleImage.setTransform({
width: 440,
Expand All @@ -89,10 +89,10 @@
</h6>

<div class="article-category-date">
{{ newsEntry.postDate|date('m.d.Y') }}
{{ newsEntry.postDate | date('m.d.Y') }}
{% if newsEntry.newsCategory | length %}
<span class="divider">|</span>
{{ (newsEntry.newsCategory|first).getLink() }}
{{ (newsEntry.newsCategory | first).getLink() }}
{% endif %}
</div>

Expand Down
Loading

0 comments on commit c731e2b

Please sign in to comment.