diff --git a/README.md b/README.md index 0fc7619..6b2cf0f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ This uses the idea of immediate components to render HTML. For example, a given - + 'content')) ?> class="menu-bar">...`. The call to `ap($prop)` generates an `id` -attribute automatically. The value of this `id` can be explicitly set by using the `$id_override` -parameter. This is useful when the elements later needs to be reloaded or regenerated dynamically. - `$prop` is an optional parameter to communicate further parameters to the component, and this corresponds to the `$prop` parameter being passed to a component's lambda function. diff --git a/index.php b/index.php index de725ca..2e15760 100644 --- a/index.php +++ b/index.php @@ -7,9 +7,9 @@ URL::MakeRoute(); ob_start(); - print(component(first(URL::$route['l-path'], 'index'), $_REQUEST['attr']['id'])); + print(component(first(URL::$route['l-path'], 'index'), array($prop['id'] => $_REQUEST['attr']['id']))); $content = ob_get_clean(); include(cfg('theme/path').'/page.'.URL::$route['content-type'].'.php'); - Log::audit('page:'.URL::$route['page'], URL::$route['l-path']); \ No newline at end of file + Log::audit('page:'.URL::$route['page'], URL::$route['l-path']); diff --git a/lib/render.php b/lib/render.php index c762758..0ceae8e 100644 --- a/lib/render.php +++ b/lib/render.php @@ -50,10 +50,10 @@ } } - function component_path($file_name, $id_override = false, $prop = array(), $opt = array()) + function component_path($file_name, $prop = array(), $opt = array()) { $f = Renderer::get_func($file_name, true); - if($f) return(component($file_name, $id_override, $prop, $opt)); + if($f) return(component($file_name, $prop, $opt)); $fpath = array(); $seg = explode('/', $file_name); array_unshift($seg, ''); @@ -83,26 +83,26 @@ } } - function component_open($file_name, $id_override = false, $prop = array(), $opt = array()) + function component_open($file_name, $prop = array(), $opt = array()) { $prop['open'] = true; - return(component($file_name, $id_override, $prop, $opt)); + return(component($file_name, $prop, $opt)); } - function component_close($file_name, $id_override = false, $prop = array(), $opt = array()) + function component_close($file_name, $prop = array(), $opt = array()) { $prop['close'] = true; - return(component($file_name, $id_override, $prop, $opt)); + return(component($file_name, $prop, $opt)); } - function component_open_close($file_name, $id_override = false, $prop = array(), $opt = array()) + function component_open_close($file_name, $prop = array(), $opt = array()) { $prop['open'] = true; $prop['close'] = true; - return(component($file_name, $id_override, $prop, $opt)); + return(component($file_name, $prop, $opt)); } - function component($file_name, $id_override = false, $prop = array(), $opt = array()) + function component($file_name, $prop = array(), $opt = array()) { if($file_name == '') { @@ -110,7 +110,7 @@ return(error_banner('Component not found: '.htmlspecialchars($file_name))); } $f = Renderer::get_func($file_name); - $prop['id'] = $id_override ? $id_override : 'c'.(Renderer::$id_counter++); + $prop['id'] = $prop['id'] ? $prop['id'] : 'c'.(Renderer::$id_counter++); $prop['filename'] = $file_name; Renderer::$call_stack[] = &$prop; $result = $f($prop, $opt); @@ -132,4 +132,4 @@ function banner($s) { print(''); - } \ No newline at end of file + }