Change parse functions within templates a bit.
This commit is contained in:
parent
a41f7d64c7
commit
d0d8d82f60
6 changed files with 39 additions and 7 deletions
|
@ -273,8 +273,8 @@ class Application extends ApplicationBase
|
|||
$this->templatingInstance->addFilter('colour_get_red');
|
||||
$this->templatingInstance->addFilter('colour_get_green');
|
||||
$this->templatingInstance->addFilter('colour_get_blue');
|
||||
$this->templatingInstance->addFilter('md', 'parse_markdown');
|
||||
$this->templatingInstance->addFilter('bbcode', 'parse_bbcode');
|
||||
$this->templatingInstance->addFilter('parse_line');
|
||||
$this->templatingInstance->addFilter('parse_text');
|
||||
|
||||
$this->templatingInstance->addFunction('git_commit_hash');
|
||||
$this->templatingInstance->addFunction('git_branch');
|
||||
|
|
32
utility.php
32
utility.php
|
@ -203,6 +203,38 @@ function parse_bbcode(string $text): string
|
|||
return \Misuzu\Parsers\BBCode\BBCodeParser::instance()->parseText($text);
|
||||
}
|
||||
|
||||
function parse_text(string $text, string $parser): string
|
||||
{
|
||||
switch (strtolower($parser)) {
|
||||
case 'md':
|
||||
case 'markdown':
|
||||
return \Misuzu\Parsers\MarkdownParser::instance()->parseText($text);
|
||||
|
||||
case 'bb':
|
||||
case 'bbcode':
|
||||
return \Misuzu\Parsers\BBCode\BBCodeParser::instance()->parseText($text);
|
||||
|
||||
default:
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
function parse_line(string $line, string $parser): string
|
||||
{
|
||||
switch (strtolower($parser)) {
|
||||
case 'md':
|
||||
case 'markdown':
|
||||
return \Misuzu\Parsers\MarkdownParser::instance()->parseLine($line);
|
||||
|
||||
case 'bb':
|
||||
case 'bbcode':
|
||||
return \Misuzu\Parsers\BBCode\BBCodeParser::instance()->parseLine($line);
|
||||
|
||||
default:
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
|
||||
function render_error(int $code, string $template = 'errors.%d'): string
|
||||
{
|
||||
http_response_code($code);
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<div class="changelog__change__column changelog__change__column--change-info">
|
||||
<div class="changelog__change__text">
|
||||
{% if change.change_text|length >= 1 %}
|
||||
{{ change.change_text|md|raw }}
|
||||
{{ change.change_text|parse_text('md')|raw }}
|
||||
{% else %}
|
||||
<p>This change has no additional notes.</p>
|
||||
{% endif %}
|
||||
|
|
|
@ -291,9 +291,9 @@
|
|||
</div>
|
||||
<div class="forum__post__content__text">
|
||||
{% if post.post_parse == 2 %}
|
||||
{{ post.post_text|escape|md|raw }}
|
||||
{{ post.post_text|escape|parse_text('md')|raw }}
|
||||
{% elseif post.post_parse == 1 %}
|
||||
{{ post.post_text|escape|bbcode|raw }}
|
||||
{{ post.post_text|escape|parse_text('bb')|raw }}
|
||||
{% else %}
|
||||
{{ post.post_text|escape }}
|
||||
{% endif %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<div class="container__content news__preview__content">
|
||||
<div class="news__preview__text">
|
||||
{{ post.post_text|first_paragraph|md|raw }}
|
||||
{{ post.post_text|first_paragraph|parse_text('md')|raw }}
|
||||
</div>
|
||||
|
||||
<div class="news__preview__info">
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<div class="container__content news__post__content">
|
||||
<div class="news__post__text">
|
||||
{{ post.post_text|md|raw }}
|
||||
{{ post.post_text|parse_text('md')|raw }}
|
||||
</div>
|
||||
|
||||
<div class="news__sidebar news__post__details">
|
||||
|
|
Loading…
Add table
Reference in a new issue