Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Easy Variable Dumping #42

Merged
merged 1 commit into from

2 participants

@thisislawatts

Perhaps I am the last var_dumper, but I find myself losing track of what is what almost as often as I know what is what.

So figured it could be worth adding an easy debug functions into the extensions. Included two flavours to cover possible outputs.

I know this is in Twigkit somwhere but having only met their code/documentation a little while ago adding it here seemed the lightest way to add the behaviour.

@kolber
Owner

Very handy, cheers.

@kolber kolber merged commit 3de6607 into kolber:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 22, 2012
  1. Adding debug into Stacey

    Luke Watts authored
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +19 −0 extensions/twig-extensions.inc.php
View
19 extensions/twig-extensions.inc.php
@@ -25,12 +25,30 @@ public function getFunctions() {
return array(
'sortbydate' => new Twig_Function_Method($this, 'sortbydate'),
'sortby' => new Twig_Function_Method($this, 'sortby'),
+ 'debug' => new Twig_Function_Method($this, 'var_dumper'),
+ 'pebug' => new Twig_Function_Method($this, 'var_dumper_pre'),
'get' => new Twig_Filter_Method($this, 'get'),
'slice' => new Twig_Filter_Method($this, 'slice'),
'resize_path' => new Twig_Filter_Method($this, 'resize_path'),
);
}
+ #
+ # dump out our var for easy debugging
+ #
+ public function var_dumper($input) {
+ var_dump( $input );
+ }
+
+ #
+ # dump out our var for easy debugging ++ Now with Extra Pre's
+ #
+ public function var_dumper_pre($input) {
+ echo "<pre>";
+ print_r( $input );
+ echo "</pre>";
+ }
+
#
# manually change page context
#
@@ -62,6 +80,7 @@ function resize_path($img_path, $max_width = '100', $max_height = '100', $ratio
}
}
+
#
# allow offsetting and limiting arrays
#
Something went wrong with that request. Please try again.