OSDN Git Service

disable HTML escaping when rendering Mustache templates
authorscribu <mail@scribu.net>
Fri, 29 Nov 2013 21:00:26 +0000 (23:00 +0200)
committerscribu <mail@scribu.net>
Fri, 29 Nov 2013 21:41:38 +0000 (23:41 +0200)
php/utils.php
templates/man-params.mustache
templates/man.mustache
templates/post_type_extended.mustache
templates/taxonomy_extended.mustache
templates/wp-config.mustache

index c3abfdf..1972c25 100644 (file)
@@ -340,13 +340,20 @@ function run_mysql_command( $cmd, $assoc_args, $descriptors = null ) {
        if ( $r ) exit( $r );
 }
 
+/**
+ * Render PHP or other types of files using Mustache templates.
+ *
+ * IMPORTANT: Automatic HTML escaping is disabled!
+ */
 function mustache_render( $template_name, $data ) {
        if ( ! file_exists( $template_name ) )
                $template_name = WP_CLI_ROOT . "/templates/$template_name";
 
        $template = file_get_contents( $template_name );
 
-       $m = new \Mustache_Engine;
+       $m = new \Mustache_Engine( array(
+               'escape' => function ( $val ) { return $val; }
+       ) );
 
        return $m->render( $template, $data );
 }
index 990412b..dd848d8 100644 (file)
@@ -1,7 +1,7 @@
 ## GLOBAL PARAMETERS
 
 {{#parameters}}
-  {{{synopsis}}}
+  {{synopsis}}
       {{desc}}
 
 {{/parameters}}
index 6767c83..a42acbc 100644 (file)
@@ -1,20 +1,20 @@
 ## NAME
 
-       {{{name}}}
+       {{name}}
 
 ## DESCRIPTION
 
-       {{{shortdesc}}}
+       {{shortdesc}}
 
 ## SYNOPSIS
 
-       {{{synopsis}}}
+       {{synopsis}}
 
 {{#has-subcommands}}
 ## SUBCOMMANDS
 
 {{#subcommands}}
-       {{{.}}}
+       {{.}}
 {{/subcommands}}
 
 {{/has-subcommands}}
index 9acbbb5..b8250fd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 function {{machine_name}}_init() {
-{{{output}}}
+{{output}}
 }
 add_action( 'init', '{{machine_name}}_init' );
 
index 8e0e1a5..e2e584a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 function {{machine_name}}_init() {
-{{{output}}}
+{{output}}
 }
 add_action( 'init', '{{machine_name}}_init' );
index d0cec68..e708cc1 100644 (file)
@@ -36,7 +36,7 @@ define('DB_COLLATE', '{{dbcollate}}');
  * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
  * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
  */
-{{{keys-and-salts}}}
+{{keys-and-salts}}
 /**#@-*/
 {{/keys-and-salts}}
 
@@ -58,7 +58,7 @@ $table_prefix = '{{dbprefix}}';
  */
 define('WPLANG', '{{locale}}');
 
-{{{extra-php}}}
+{{extra-php}}
 
 /* That's all, stop editing! Happy blogging. */