Skip to content

Instantly share code, notes, and snippets.

@EpocSquadron
Created February 22, 2020 05:57
Show Gist options
  • Save EpocSquadron/7b637a97b208f998b02167b876eb6f29 to your computer and use it in GitHub Desktop.
Save EpocSquadron/7b637a97b208f998b02167b876eb6f29 to your computer and use it in GitHub Desktop.
{% include "_components/breadcrumbNavigation" with {
content: {
list: [
{
hyperlink: {
url: url('blog'),
text: 'blog'|t('site/navigation')
}
},
{
hyperlink: {
url: entry.url,
text: entry.blogHeading
}
},
]
}
} %}
{% if content.comparisons|length %}
<section class="comparisonTable {{ content['className'] ?? null }}" {% if content['idName'] ?? null %}id="{{ content['idName'] }}"{% endif %}>
<div class="comparisonTable__container container ">
<div class="comparisonTable__content">
<div class="comparisonTable__main">
<div class="comparisonTable__table-outer">
<table class="comparisonTable__table">
<thead>
<th class="comparisonTable__table-heading">{{ 'col 1'|t }}</th>
<th class="comparisonTable__table-heading">{{ 'col 2'|t }}</th>
<th class="comparisonTable__table-heading">{{ 'col 3'|t }}</th>
</thead>
<tbody>
{% for comparisons in content.comparisons %}
<tr>
<td class="comparisonTable__table-value">{{ comparisons.col1 }}</td>
<td class="comparisonTable__table-value">{{ comparisons.col2 }}</td>
<td class="comparisonTable__table-value">{{ comparisons.col3 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endif %}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=twig %{
add-highlighter window/twig ref twig
}
hook global WinSetOption filetype=(?!twig).* %{
remove-highlighter window/twig
}
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](twig) %{
set-option buffer filetype twig
}
hook global BufCreate .+\.html %[
try %[
execute-keys \%s \{\%|\{\{ <ret>
set-option buffer filetype twig
]
]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=twig %{
require-module twig
}
hook -group twig-highlight global WinSetOption filetype=twig %{
add-highlighter window/twig ref twig
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/twig }
}
provide-module twig %[
require-module html
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/twig regions
add-highlighter shared/twig/code default-region ref html
add-highlighter shared/twig/scope region '\{%' '%\}' group
add-highlighter shared/twig/expansion region '\{\{' '\}\}' group
add-highlighter shared/twig/comment region '\{#' '#\}' fill comment
# Wrapping delimiter highlighting
add-highlighter shared/twig/scope/ regex \{%|%\} 0:meta
add-highlighter shared/twig/expansion/ regex \{\{|\}\} 0:meta
# Operators
#add-highlighter shared/twig/scope/ regex \s(\+|-|\/\/?|\*\*?|and|or|not|s-and|s-or|s-xor|starts with|ends with|matches|===?|!=|<=?|>=?|\?\?|\?:|~|\|)\s 1:operator
add-highlighter shared/twig/scope/ regex \s(\?\?\??|={1,3}|!==?|\+)\s 1:operator
# Tags
add-highlighter shared/twig/scope/ regex \{%\s+((end)?(apply|autoescape|block|deprecated|do|embed|extends|flush|for|from|if|import|include|macro|sandbox|set|use|verbatim|with))\b 1:keyword
# If internals
add-highlighter shared/twig/scope/ regex if[^\n]+\b(and|or|is|in)\b 1:keyword
# Include internals
add-highlighter shared/twig/scope/ regex include[^\n]+\b(with)\b 1:keyword
# Filters
add-highlighter shared/twig/expansion/ regex \|\s*(abs|batch|capitalize|column|convert_encoding|country_name|currency_name|currency_symbol|data_uri|date|date_modify|default|escape|filter|first|format|format_currency|format_date|format_datetime|format_number|format_time|html_to_markdown|inky_to_html|inline_css|join|json_encode|keys|language_name|last|length|locale_name|lower|map|markdown_to_html|merge|nl2br|number_format|raw|reduce|replace|reverse|round|slice|sort|spaceless|split|striptags|timezone_name|title|trim|u|upper|url_encode)\b 1:function
# Functions
add-highlighter shared/twig/scope/ regex (attribute|block|constant|country_timezones|cycle|date|dump|html_classes|include|max|min|parent|random|range|source|template_from_string)\( 1:function
add-highlighter shared/twig/expansion/ regex (attribute|block|constant|country_timezones|cycle|date|dump|html_classes|include|max|min|parent|random|range|source|template_from_string)\( 1:function
# Tests
add-highlighter shared/twig/scope/ regex is\s+(constant|defined|divisibleby|empty|even|iterable|null|odd|sameas) 1:builtin
# Values
add-highlighter shared/twig/scope/double_string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/twig/expansion/double_string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/twig/scope/single_string region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/twig/expansion/single_string region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/twig/scope/ regex "(\b|-)[0-9]*\.?[0-9]+\b" 0:value
add-highlighter shared/twig/scope/ regex \b(false|null|true)\b 0:value
add-highlighter shared/twig/expansion/ regex "(\b|-)[0-9]*\.?[0-9]+\b" 0:value
add-highlighter shared/twig/expansion/ regex \b(false|null|true)\b 0:value
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment