Skip to content

Commit

Permalink
1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
qstudio committed Nov 26, 2020
1 parent 1465527 commit 2064637
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.6.1 ###

* New: [ debug ] flag added to Willows to allow for quickl debugging of single Willow

### 1.6.0 ###

* New: New loops functionality more stable, more flexible and potentially faster.
Expand Down
9 changes: 5 additions & 4 deletions library/parse/flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,38 +103,39 @@ public static function get( $string = null, $use = 'willow' ){
$flags_array = filter\method::prepare([ 'filters' => $flags, 'use' => $use ] );

// h::log( $flags_array );
// h::log( 'use: '.$use );

// assign filters based on use-case ##
switch( $use ) {

default :
case "willow" :

// @todo - validate that flags are allowed again self::$flags_willows ##
// @todo - validate that flags are allowed against self::$flags_willows ##

self::$flags_willow = $flags_array;

break ;

case "php_function" :

// @todo - validate that flags are allowed again self::$flags_php ##
// @todo - validate that flags are allowed against self::$flags_php ##

self::$flags_php_function = $flags_array;

break ;

case "php_variable" :

// @todo - validate that flags are allowed again self::$flags_php ##
// @todo - validate that flags are allowed against self::$flags_php ##

self::$flags_php_variable = $flags_array;

break ;

case "comment" :

// @todo - validate that flags are allowed again self::$flags_comment ##
// @todo - validate that flags are allowed against self::$flags_comment ##

self::$flags_comment = $flags_array;

Expand Down
40 changes: 34 additions & 6 deletions library/parse/willows.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class willows extends willow\parse {

private static

$willow_context,
$willow_task,
$willow_matches, // array of matches ##
$willow,
// $willow_match, // full string matched ##
Expand All @@ -34,6 +36,8 @@ class willows extends willow\parse {

private static function reset(){

self::$willow_context = false;
self::$willow_task = false;
self::$flags_willow = false;
self::$willow_hash = false;
self::$willow = false;
Expand Down Expand Up @@ -144,6 +148,7 @@ public static function format( $match = null, $args = null, $process = 'secondar

// look for Willow flags -- assigned to a filter for use late on, pre-rendering ##
self::$willow = flags::get( self::$willow, 'willow' );
// h::log( self::$flags_willow );

// clean up ##
self::$willow = trim( self::$willow );
Expand Down Expand Up @@ -171,6 +176,12 @@ public static function format( $match = null, $args = null, $process = 'secondar

}

// grab context and task for debugging ##
self::$willow_context = explode( '~', self::$willow, 2 )[0];
self::$willow_task = explode( '~', self::$willow, 2 )[1];

// h::log( 'Willow Context: '.self::$willow_context.' // Task: '.self::$willow_task );

// h::log( $args );

// get position of first arg_o and position of last arg_c ( in case the string includes additional args )
Expand Down Expand Up @@ -202,7 +213,7 @@ public static function format( $match = null, $args = null, $process = 'secondar
// check for loops in argument string - might be one or multiple ##
if( $loops = loops::has( self::$argument_string ) ){

// h::log( $args['task'].'~>n:>HAS a loop so taking part of config string as markup' );
// h::log( self::$willow_task.'~>n:>HAS a loop so taking part of config string as markup' );
// h::log( 'd:>HAS a loop so taking part of config string as markup' );

// we need the entire markup, without the flags ##
Expand All @@ -218,7 +229,7 @@ public static function format( $match = null, $args = null, $process = 'secondar
) {

// h::log( 'template -> '.$decode_flags['markup']['template'] );
// h::log( $args['task'].'~>n:>FLAG set so take just loop markup: '.$loop['markup'] );
// h::log( self::$willow_task.'~>n:>FLAG set so take just loop markup: '.$loop['markup'] );
// h::log( 'd:>Flags set, so take just loop markup: '.$loop['markup'] );

self::$arguments = core\method::parse_args(
Expand All @@ -231,7 +242,7 @@ public static function format( $match = null, $args = null, $process = 'secondar

} else {

// h::log( $args['task'].'~>n:>NO flags, so take whole string: '.self::$argument_string );
// h::log( self::$willow_task.'~>n:>NO flags, so take whole string: '.self::$argument_string );
// h::log( 'd:>No Flags, so take whole string: '.self::$argument_string );

self::$arguments = core\method::parse_args(
Expand Down Expand Up @@ -269,7 +280,7 @@ public static function format( $match = null, $args = null, $process = 'secondar
|| ! is_array( self::$arguments )
) {

h::log( $args['task'].'~>d:>No array arguments found in willow args, but perhaps we still have filters in the vars' );
h::log( self::$willow_task.'~>d:>No array arguments found in willow args, but perhaps we still have filters in the vars' );
// h::log( $args['task'].'~>d:>'.self::$argument_string );

// check for variable filters ##
Expand Down Expand Up @@ -410,19 +421,36 @@ public static function format( $match = null, $args = null, $process = 'secondar
);
}

// debug => output debug data for this single Willow ##
if(
self::$flags_willow // flags set ##
&& is_array( self::$flags_willow ) // is an array
&& in_array( 'debug', self::$flags_willow ) // debug defined ##
) {

self::$arguments = core\method::parse_args(
self::$arguments,
[
'config' => [
'debug' => true
]
]
);
}

// collect current process state ##
render\args::collect();

// pass args, if set ##
if( self::$arguments ){

// h::log( 'passing args array to: '.self::$class.'::'.self::$method );
h::log( self::$willow_task.'~>n:>Passing args array to: '.self::$class.'::'.self::$method );
// h::log( self::$arguments );
self::$return = call_user_func_array( self::$willow_array, [ 0 => self::$arguments ] ); // 0 index is for static class args gatherer ##

} else {

// h::log( 'NOT passing args array to: '.self::$class.'::'.self::$method );
h::log( self::$willow_task.'~>n:>NOT passing args array to: '.self::$class.'::'.self::$method );
self::$return = call_user_func_array( self::$willow_array );

}
Expand Down
2 changes: 1 addition & 1 deletion library/render/args.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public static function is_enabled()
) {

// log ##
h::log( self::$args['task'].'~>n:>No enable defined in $args or enable field found for task: "'.self::$args['task'].'"');
h::log( self::$args['task'].'~>n:>No enable defined in $args NOR enable field found for task: "'.self::$args['task'].'"');

return true;

Expand Down
45 changes: 25 additions & 20 deletions library/render/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,40 @@ class log extends willow\render {
public static function set( Array $args = null ){

// h::log( 'e:>'.$args['task'] );
// h::log( self::$args['config'] );
// h::log( self::$args['config']['debug'] );

if (
! isset( self::$args['config']['debug'] )
|| false === self::$args['config']['debug']
|| 'false' == self::$args['config']['debug']
|| ! self::$args['config']['debug']
isset( self::$args['config']['debug'] )
&&
(
'1' === self::$args['config']['debug']
|| true === self::$args['config']['debug']
)
// || 'false' == self::$args['config']['debug']
// || ! self::$args['config']['debug']
) {

// h::log( 'd:>Debugging is turned OFF for : "'.$args['task'].'"' );
// h::log( 'd:>Debugging is turned ON for : "'.$args['task'].'"' );

return false;
// filter in group to debug ##
\add_filter( 'willow/core/log/debug', function( $key ) use ( $args ){
// h::log( $key );
$return = is_array( $key ) ? array_merge( $key, [ $args['task'] ] ) : [ $key, $args['task'] ];
// h::log( $return );
return
$return;
}
);

}
// return ##
return true;

h::log( 'd:>Debugging is turned ON for : "'.$args['task'].'"' );
}

// filter in group to debug ##
\add_filter( 'willow/core/log/debug', function( $key ) use ( $args ){
// h::log( $key );
$return = is_array( $key ) ? array_merge( $key, [ $args['task'] ] ) : [ $key, $args['task'] ];
// h::log( $return );
return
$return;
}
);
// default ##
// h::log( 'd:>Debugging is turned OFF for : "'.$args['task'].'"' );

// return ##
return true;
return false;

// debug the group ##
// return core\log::write( $args['task'] );
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Tags:** Simple, logic-less, procedural, semantic, markup, language
**Requires at least:** 5.0
**Tested up to:** 5.5.3
**Stable tag:** 1.6.0
**Stable tag:** 1.6.1
**License:** GPL2

Willow ~ A logic-less template engine built for WordPress.
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: Simple, logic-less, procedural semantic markup language
Requires at least: 5.0
Tested up to: 5.5.3
Requires PHP: 7.0
Stable tag: 1.6.0
Stable tag: 1.6.1
License: GPL2

Willow ~ A logic-less template engine built for WordPress.
Expand Down
5 changes: 3 additions & 2 deletions willow.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Plugin Name: Willow
* Plugin URI: https://www.qstudio.us
* Description: Willow is a Simple, logic-less, procedural semantic template engine built for WordPress
* Version: 1.6.0
* Version: 1.6.1
* Author: Q Studio
* Author URI: https://www.qstudio.us
* License: GPL
Expand Down Expand Up @@ -46,7 +46,7 @@ class willow {
private static $instance = null;

// Plugin Settings
const version = '1.6.0';
const version = '1.6.1';
const text_domain = 'willow'; // for translation ##

protected static
Expand Down Expand Up @@ -309,6 +309,7 @@ class willow {
// allowed flags - currently not referenced or filtered, but might be in future release ##
$flags = [

'debug', // short cut to debug a single Willow
'buffer', // php_function, willow ##
'return', // php_function ##
'array', // arguments ##
Expand Down

0 comments on commit 2064637

Please sign in to comment.