blob: 93353d751c59d4ce8f6a79605c1e1158a78081df [file] [log] [blame]
/**
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{namespace com.google.gerrit.server.mail.template}
/*
* Private templates that cannot be overridden.
*/
/**
* Private template to generate "View Change" buttons.
* @param email
*/
{template .ViewChangeButton private="true" autoescape="strict" kind="html"}
<a href="{$email.changeUrl}">View Change</a>
{/template}
/**
* Private template to render PRE block with consistent font-sizing.
* @param content
*/
{template .Pre private="true" autoescape="strict" kind="html"}
{let $preStyle kind="css"}
font-family: monospace,monospace; // Use this to avoid browsers scaling down
// monospace text.
white-space: pre-wrap;
{/let}
<pre style="{$preStyle}">{$content|changeNewlineToBr}</pre>
{/template}
/**
* Take a list of unescaped comment blocks and emit safely escaped HTML to
* render it nicely with wiki-like format.
*
* Each block is a map with a type key. When the type is 'paragraph', or 'pre',
* it also has a 'text' key that maps to the unescaped text content for the
* block. If the type is 'list', the map will have a 'items' key which maps to
* list of unescaped list item strings. If the type is quote, the map will have
* a 'quotedBlocks' key which maps to the blocks contained within the quote.
*
* This mechanism encodes as little structure as possible in order to depend on
* the Soy autoescape mechanism for all of the content.
*
* @param content
*/
{template .WikiFormat private="true" autoescape="strict" kind="html"}
{let $blockquoteStyle kind="css"}
border-left: 1px solid #aaa;
margin: 10px 0;
padding: 0 10px;
{/let}
{let $pStyle kind="css"}
white-space: pre-wrap;
word-wrap: break-word;
{/let}
{foreach $block in $content}
{if $block.type == 'paragraph'}
<p style="{$pStyle}">{$block.text|changeNewlineToBr}</p>
{elseif $block.type == 'quote'}
<blockquote style="{$blockquoteStyle}">
{call .WikiFormat}{param content: $block.quotedBlocks /}{/call}
</blockquote>
{elseif $block.type == 'pre'}
{call .Pre}{param content: $block.text /}{/call}
{elseif $block.type == 'list'}
<ul>
{foreach $item in $block.items}
<li>{$item}</li>
{/foreach}
</ul>
{/if}
{/foreach}
{/template}