Browse files

Added changelog, preparing 0.0.3

  • Loading branch information...
1 parent 0d57eb2 commit 274e783fc89b4911ab3f040655538ef498737091 @endorama committed Jun 17, 2011
Showing with 56 additions and 31 deletions.
  1. +1 −0 .gitignore
  2. +11 −0 CHANGELOG
  3. +23 −18 config/hamltophp.php
  4. +21 −13 libraries/Hamltophp.php
View
1 .gitignore
@@ -1,2 +1,3 @@
vendor/haml
.geany
+.project
View
11 CHANGELOG
@@ -0,0 +1,11 @@
+17-06-2011 Edoardo Tenani <edoardo.tenani@gmail.com>
+
+ * Modified option array $config. Now all options are in a $config["hamltophp"]
+ array
+ * Modified library/Hamltophp.php to accept new option values
+
+12-06-2011 Edoardo Tenani <edoardo.tenani@gmail.com>
+
+ * Modified option $config["escape_html"] to FALSE by default
+
+
View
41 config/hamltophp.php
@@ -4,45 +4,48 @@
* See http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html
*/
+$config["hatmltophp"] = array (
+
/* Determines the output format. Default is XHTML 1.0
* Options:
* - xhtml ( default )
* - html4
* - html5
*/
-$config["format"] = "xhtml";
+ "format" => "xhtml",
/* Sets whether or not to escape HTML-sensitive characters in script.
* If this is true, = behaves like &=; otherwise, it behaves like !=.
* Note that if this is set, != should be used for yielding to subtemplates
* and rendering partials.
*/
-$config["escape_html"] = TRUE;
+ "escape_html" => TRUE,
/* If set to true, Haml makes no attempt to properly indent or format
* the HTML output. This significantly improves rendering performance
* but makes viewing the source unpleasant.
*/
-$config["htp_ugly"] = TRUE;
+ "ugly" => TRUE,
/* Whether or not attribute hashes and Ruby scripts designated by = or
* ~ should be evaluated. If this is true, said scripts are rendered as
* empty strings.
*/
-$config["suppress_eval"] = FALSE;
+ "suppress_eval" => FALSE,
/* The character that should wrap element attributes. This defaults to
* ' (an apostrophe). Characters of this type within the attributes will
* be escaped (e.g. by replacing them with &apos;) if the character is
* an apostrophe or a quotation mark.
*/
-$config["attr_wrapper"] = "'";
+ "attr_wrapper" => "'",
/* A list of tag names that should be automatically self-closed if they
* have no content. This can also contain regular expressions that match
* tag names.
*/
-$config["autoclose"] = array('meta','img','link','br','hr','input','area','param','col','base');
+ "autoclose" => array('meta','img','link','br','hr','input','area','param','col','base'),
+
########################################################################
/*
@@ -52,28 +55,30 @@
/* Enable cache for parsed haml? If yes all the parsed haml files will
* be saved as php files in the cache folder
*/
-$config["htp_cache"] = TRUE;
+ "cache" => TRUE,
/* The cache directory in which haml parsed file will be saved.
*/
-$config["htp_cache_dir"] = APPPATH . "cache";
+ "cache_dir" => APPPATH . "cache",
/* The directory in which haml files will be
*/
-$config["htp_haml_dir"] = APPPATH . "views";
+ "haml_dir" => APPPATH . "views",
/* Bind a function to a filter usable in HAML files
*
* plain, javascript, css, cdata, escaped, php, preserve are binded.
* To override options or to add filter, simply add a new array item:
* 'filter_name' => 'filter_function'
*/
-$config["filters"] = array(
- 'plain' => 'HamlUtilities::plain',
- 'javascript' => 'HamlUtilities::javascript',
- 'css' => 'HamlUtilities::css',
- 'cdata' => 'HamlUtilities::cdata',
- 'escaped' => 'HamlUtilities::escaped',
- 'php' => 'HamlUtilities::php',
- 'preserve' => 'HamlUtilities::preserve',
-);
+ "filters" => array(
+ 'plain' => 'HamlUtilities::plain',
+ 'javascript' => 'HamlUtilities::javascript',
+ 'css' => 'HamlUtilities::css',
+ 'cdata' => 'HamlUtilities::cdata',
+ 'escaped' => 'HamlUtilities::escaped',
+ 'php' => 'HamlUtilities::php',
+ 'preserve' => 'HamlUtilities::preserve',
+ ),
+
+); // ends hatmltophp config var
View
34 libraries/Hamltophp.php
@@ -33,15 +33,15 @@
* @subpackage Libraries
* @category Libraries
*
- * @version 0.0.2
+ * @version 0.0.3
* @author Edoardo Tenani <edoardo.tenani@gmail.com>
* @license GNU Public License 2.0 or greater
* <http://opensource.org/licenses/gpl-2.0.php>
* @copyright Copyright (c) 2011, Edoardo Tenani
* @link
*/
-define('HAMLTOPHP_VERSION', '0.0.2');
+define('HAMLTOPHP_VERSION', '0.0.3');
require_once BASEPATH . "../sparks/hamltophp/" . HAMLTOPHP_VERSION . "/vendor/haml/Haml.php";
@@ -63,26 +63,34 @@ class Hamltophp {
*/
public $parser;
+ /**
+ * Configuration for Hamltophp
+ *
+ * @access protected
+ * @var array
+ */
+ protected $config;
function __construct() {
self::$instance = $this;
$CI =& get_instance();
$CI->config->load("hamltophp");
+ $this->config = $CI->config->item("hamltophp");
- $this->parser = new HamlFileCache($CI->config->item("htp_haml_dir"), $CI->config->item("htp_cache_dir"));
+ $this->parser = new HamlFileCache($CI->config->item("haml_dir"), $CI->config->item("cache_dir"));
if ( isset ($CI->config) && !empty($CI->config) ) {
- $this->parser->options["format"] = $CI->config->item("format");
- $this->parser->options["escape_html"] = $CI->config->item("escape_html");
- $this->parser->options["htp_ugly"] = $CI->config->item("htp_ugly");
- $this->parser->options["suppress_eval"] = $CI->config->item("suppress_eval");
- $this->parser->options["attr_wrapper"] = $CI->config->item("attr_wrapper");
- $this->parser->options["autoclose"] = $CI->config->item("autoclose");
- $this->parser->options["ugly"] = $CI->config->item("htp_ugly");
- $this->parser->options["filters"] = $CI->config->item("filters");
- $this->parser->forceUpdate = $CI->config->item("htp_cache");
+ $this->parser->options["format"] = $this->config["format"];
+ $this->parser->options["escape_html"] = $this->config["escape_html"];
+ $this->parser->options["htp_ugly"] = $this->config["htp_ugly"];
+ $this->parser->options["suppress_eval"] = $this->config["suppress_eval"];
+ $this->parser->options["attr_wrapper"] = $this->config["attr_wrapper"];
+ $this->parser->options["autoclose"] = $this->config["autoclose"];
+ $this->parser->options["ugly"] = $this->config["ugly"];
+ $this->parser->options["filters"] = $this->config["filters"];
+ $this->parser->forceUpdate = $this->config["cache"];
}
$CI->load->helper("hamltophp");
@@ -196,7 +204,7 @@ static public function get_instance() {
* @return string the parsed HTML/PHP content
*/
function parse($template, $data = array()) {
- return $this->parser->haml($template, $data);;
+ return $this->parser->haml($template, $data);
}

0 comments on commit 274e783

Please sign in to comment.