diff options
author | Derek Allard <derek.allard@ellislab.com> | 2010-01-15 18:10:56 +0100 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2010-01-15 18:10:56 +0100 |
commit | d827058bb0b1d2b54f7cb0e8343885cedac43334 (patch) | |
tree | 3c09c764f3d8eb34b93db0d540bddc79566add8a /system/libraries | |
parent | 3e9519e07af366f9bd7b48de34db689f573d37ea (diff) |
adding parse_string method
adding null values generating an empty cell in table lib
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Parser.php | 51 | ||||
-rw-r--r-- | system/libraries/Table.php | 2 |
2 files changed, 46 insertions, 7 deletions
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 399b14b2d..56d27e7da 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -29,11 +29,11 @@ class CI_Parser { var $l_delim = '{'; var $r_delim = '}'; var $object; - + /** * Parse a template * - * Parses pseudo-variables contained in the specified template, + * Parses pseudo-variables contained in the specified template view, * replacing them with the data in the second param * * @access public @@ -46,12 +46,50 @@ class CI_Parser { { $CI =& get_instance(); $template = $CI->load->view($template, $data, TRUE); - + + return $this->_parse($template, $data, $return); + } + + // -------------------------------------------------------------------- + + /** + * Parse a String + * + * Parses pseudo-variables contained in the specified string, + * replacing them with the data in the second param + * + * @access public + * @param string + * @param array + * @param bool + * @return string + */ + function parse_string($template, $data, $return = FALSE) + { + return $this->_parse($template, $data, $return); + } + + // -------------------------------------------------------------------- + + /** + * Parse a template + * + * Parses pseudo-variables contained in the specified template, + * replacing them with the data in the second param + * + * @access public + * @param string + * @param array + * @param bool + * @return string + */ + function _parse($template, $data, $return = FALSE) + { if ($template == '') { return FALSE; } - + foreach ($data as $key => $val) { if (is_array($val)) @@ -63,12 +101,13 @@ class CI_Parser { $template = $this->_parse_single($key, (string)$val, $template); } } - + if ($return == FALSE) { + $CI =& get_instance(); $CI->output->append_output($template); } - + return $template; } diff --git a/system/libraries/Table.php b/system/libraries/Table.php index a990d406c..6d36121f2 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -260,7 +260,7 @@ class CI_Table { { $out .= $this->template['cell_'.$name.'start']; - if ($cell === "") + if ($cell === "" OR $cell === NULL) { $out .= $this->empty_cells; } |