Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work done on #61. This should be the last of it, I hope.

  • Loading branch information...
commit aedf5e87986dcd8995cdafed424b23808e6ed721 1 parent a06b0f1
@bobdenotter authored
Showing with 18 additions and 15 deletions.
  1. +1 −1  app/src/Bolt/Content.php
  2. +17 −14 app/src/Bolt/TwigExtension.php
View
2  app/src/Bolt/Content.php
@@ -591,7 +591,7 @@ public function excerpt($length = 200)
$excerpt = trimText(strip_tags($excerpt), $length) ;
- return $excerpt;
+ return new \Twig_Markup($excerpt, 'UTF-8');
}
View
31 app/src/Bolt/TwigExtension.php
@@ -90,10 +90,15 @@ public function printDump($var)
*/
public function excerpt($content, $length = 200)
{
-
- // If it's an contenct object, let the object handle it.
+ // If it's an content object, let the object handle it.
if (is_object($content)) {
- return $content->excerpt($length);
+
+ if (method_exists($content, 'excerpt')) {
+ return $content->excerpt($length);
+ } else {
+ $output = $content;
+ }
+
} elseif (is_array($content)) {
// Assume it's an array, strip some common fields that we don't need, implode the rest..
@@ -116,7 +121,7 @@ public function excerpt($content, $length = 200)
$output = trimText(strip_tags($output), $length) ;
- return $output;
+ return new \Twig_Markup($output, 'UTF-8');
}
@@ -128,7 +133,7 @@ public function trim($content, $length = 200)
$output = trimText(strip_tags($content), $length) ;
- return $output;
+ return new \Twig_Markup($output, 'UTF-8');
}
@@ -141,7 +146,7 @@ public function markdown($content)
include_once __DIR__. "/../../classes/markdown.php";
$output = Markdown($content) ;
- return $output;
+ return new \Twig_Markup($output, 'UTF-8');
}
@@ -389,7 +394,7 @@ public function request($parameter, $first = "")
*/
public function trans($str)
{
- return $str;
+ return $str;
}
@@ -448,16 +453,15 @@ public function fancybox($filename = "", $width = 100, $height = 100, $crop = ""
$thumbnail = $this->thumbnail($filename, $width, $height, $crop);
$large = $this->thumbnail($filename, 1000, 1000, 'r');
- $fancybox = sprintf('<a href="%s" class="fancybox" rel="fancybox" title="Image: %s">
+ $output = sprintf('<a href="%s" class="fancybox" rel="fancybox" title="Image: %s">
<img src="%s" width="%s" height="%s"></a>',
$large, $filename, $thumbnail, $width, $height );
- return $fancybox;
-
} else {
- return "&nbsp;";
+ $output = "&nbsp;";
}
+ return new \Twig_Markup($output, 'UTF-8');
}
@@ -499,8 +503,7 @@ public function editable($html, $content, $field)
$html
);
- return $output;
-
+ return new \Twig_Markup($output, 'UTF-8');
}
@@ -627,7 +630,7 @@ public function randomquote()
$quote = sprintf("“%s”\n<cite>— %s</cite>", $randomquote[0], $randomquote[1]);
- return $quote;
+ return new \Twig_Markup($quote, 'UTF-8');
}
Please sign in to comment.
Something went wrong with that request. Please try again.