Skip to content

Commit

Permalink
Add proper twig escapes into a new theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Oct 16, 2020
1 parent 70d9d2d commit d7d847d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

1. [](#improved)
* User return typehints in plugin.php
* Add proper twig escapes into a new theme

# v1.4.1
## 05/20/2020
Expand Down
2 changes: 1 addition & 1 deletion components/theme/pure-blank/templates/default.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'partials/base.html.twig' %}

{% block content %}
{{ page.content }}
{{ page.content|raw }}
{% endblock %}
2 changes: 1 addition & 1 deletion components/theme/pure-blank/templates/error.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
{% block content %}
<div class="lead text-center">
<h1>Error!</h1>
{{ page.content }}
{{ page.content|raw }}
</div>
{% endblock %}
14 changes: 7 additions & 7 deletions components/theme/pure-blank/templates/partials/base.html.twig
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% set theme_config = attribute(config.themes, config.system.pages.theme) %}
<!DOCTYPE html>
<html lang="{{ grav.language.getActive ?: grav.config.site.default_lang }}">
<html lang="{{ (grav.language.getActive ?: grav.config.site.default_lang)|e }}">
<head>
{% block head %}
<meta charset="utf-8" />
<title>{% if header.title %}{{ header.title|e('html') }} | {% endif %}{{ site.title|e('html') }}</title>
<title>{% if header.title %}{{ header.title|e }} | {% endif %}{{ site.title|e }}</title>

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% include 'partials/metadata.html.twig' %}

<link rel="icon" type="image/png" href="{{ url('theme://images/logo.png') }}" />
<link rel="canonical" href="{{ page.url(true, true) }}" />
<link rel="icon" type="image/png" href="{{ url('theme://images/logo.png')|e }}" />
<link rel="canonical" href="{{ page.url(true, true)|e }}" />
{% endblock head %}

{% block stylesheets %}
Expand All @@ -29,14 +29,14 @@
{{ assets.js()|raw }}
{% endblock %}
</head>
<body id="top" class="{{ page.header.body_classes }}">
<body id="top" class="{{ page.header.body_classes|e }}">

{% block header %}
<div class="header">
<div class="wrapper padding">
<a class="logo left" href="{{ home_url }}">
<a class="logo left" href="{{ home_url|e }}">
<i class="fa fa-rebel"></i>
{{ config.site.title }}
{{ config.site.title|e }}
</a>
{% block header_navigation %}
<nav class="main-nav">
Expand Down
31 changes: 15 additions & 16 deletions components/theme/pure-blank/templates/partials/navigation.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
{% for p in page.children.visible %}
{% set current_page = (p.active or p.activeChild) ? 'selected' : '' %}
{% if p.children.visible.count > 0 %}
<li class="has-children {{ current_page }}">
<a href="{{ p.url }}">
{% if p.header.icon %}<i class="fa fa-{{ p.header.icon }}"></i>{% endif %}
{{ p.menu }}
<li class="has-children {{ current_page|e }}">
<a href="{{ p.url|e }}">
{% if p.header.icon %}<i class="fa fa-{{ p.header.icon|e }}"></i>{% endif %}
{{ p.menu|e }}
</a>
<ul>
{{ _self.loop(p) }}
</ul>
</li>
{% else %}
<li class="{{ current_page }}">
<a href="{{ p.url }}">
{% if p.header.icon %}<i class="fa fa-{{ p.header.icon }}"></i>{% endif %}
{{ p.menu }}
<li class="{{ current_page|e }}">
<a href="{{ p.url|e }}">
{% if p.header.icon %}<i class="fa fa-{{ p.header.icon|e }}"></i>{% endif %}
{{ p.menu|e }}
</a>
</li>
{% endif %}
Expand All @@ -28,21 +28,20 @@
{% else %}
{% for page in pages.children.visible %}
{% set current_page = (page.active or page.activeChild) ? 'selected' : '' %}
<li class="{{ current_page }}">
<a href="{{ page.url }}">
{% if page.header.icon %}<i class="fa fa-{{ page.header.icon }}"></i>{% endif %}
{{ page.menu }}
<li class="{{ current_page|e }}">
<a href="{{ page.url|e }}">
{% if page.header.icon %}<i class="fa fa-{{ page.header.icon|e }}"></i>{% endif %}
{{ page.menu|e }}
</a>
</li>
{% endfor %}
{% endif %}
{% for mitem in site.menu %}
<li>
<a href="{{ mitem.url }}">
{% if mitem.icon %}<i class="fa fa-{{ mitem.icon }}"></i>{% endif %}
{{ mitem.text }}
<a href="{{ mitem.url|e }}">
{% if mitem.icon %}<i class="fa fa-{{ mitem.icon|e }}"></i>{% endif %}
{{ mitem.text|e }}
</a>
</li>
{% endfor %}
</ul>

0 comments on commit d7d847d

Please sign in to comment.