From 257de9b283bab8b3592a24081654787a9e0921b7 Mon Sep 17 00:00:00 2001 From: Ryan Raub Date: Thu, 10 Nov 2016 16:59:42 -0700 Subject: [PATCH 1/2] added slugify handlebars helper --- src/view/extensions/handlebars-view.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/view/extensions/handlebars-view.php b/src/view/extensions/handlebars-view.php index 28b649e..017284f 100644 --- a/src/view/extensions/handlebars-view.php +++ b/src/view/extensions/handlebars-view.php @@ -66,6 +66,7 @@ private function add_engine_helpers() { $this->add_conditional_operators(); $this->add_strip_tags(); $this->add_config(); + $this->add_slugify_helper(); } private function add_config() { @@ -89,6 +90,19 @@ function ( $template, $context, $args ) { ); } + /** + * Slugify Helper - lets you slugify any string + */ + private function add_slugify_helper() { + $this->engine->addHelper( + 'slugify', + function ( $template, $context, $args ) { + $arg = $context->get( $args ); + return slugify( $arg ); + } + ); + } + /** * No Tags Formatter * From aa3ddb4fa3ef1bc15c6812d0b1f7742c1d490134 Mon Sep 17 00:00:00 2001 From: Ryan Raub Date: Thu, 10 Nov 2016 17:04:13 -0700 Subject: [PATCH 2/2] whitespace --- src/view/extensions/handlebars-view.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/view/extensions/handlebars-view.php b/src/view/extensions/handlebars-view.php index 017284f..0614e6b 100644 --- a/src/view/extensions/handlebars-view.php +++ b/src/view/extensions/handlebars-view.php @@ -95,11 +95,11 @@ function ( $template, $context, $args ) { */ private function add_slugify_helper() { $this->engine->addHelper( - 'slugify', - function ( $template, $context, $args ) { - $arg = $context->get( $args ); - return slugify( $arg ); - } + 'slugify', + function ( $template, $context, $args ) { + $arg = $context->get( $args ); + return slugify( $arg ); + } ); }