diff --git a/Conjuro/Conjuro.php b/Conjuro/Conjuro.php index fd3aca4..b3ab218 100644 --- a/Conjuro/Conjuro.php +++ b/Conjuro/Conjuro.php @@ -216,6 +216,67 @@ } return $arr; } + + /** + * Render a set of cotnrols based on metadata list + */ + public function renderContent($metaList,$data){ + if (is_array($metaList)) + foreach($metaList as $meta){//ControlInfo + /* + $this->rhtml( + 'div', + ['id'=>$meta['container-id'],'class'=>'control '.$meta['container-class'],'data-type'=>$meta['@']], + fn()=>$this->control($meta['@'])->render($meta,$data) + ); + */ + $this->control($meta['@'])->render($meta,$data); + } + else + $this->control($metaList['@'])->render($metaList,$data); + } + + /** + * Return a string with the html attributes controlling missing data and alignments. + */ + public function htmlAttribs($attribs=null){ + $result=''; + if (!$attribs) + return $result; + foreach($attribs as $k => $v){ + $v=trim($v); + if ($v!=''){ + $result.=" $k=\"$v\""; + } + } + return $result; + } + + /** + * Open an html tag + */ + public function htmlOpen($tag,$attribs=null){ + return "<$tag".$this->htmlAttribs($attribs).'>'; + } + + /** + * Close an html tag + */ + public function htmlClose($tag){ + return ""; + } + + /** + * Html render helper + */ + public function rhtml($tag,$attribs=null,$child=null,$single=false){ + echo $this->htmlOpen($tag,$attribs); + if ($child) + $child(); + if (!$single) + echo $this->htmlClose($tag); + } + } /** @@ -279,7 +340,7 @@ class ErrorControl extends Control{ protected function renderControl($meta,$data){ $name = $this->getName(); - echo "['$name' not found]"; + echo "[Control '$name' not found]"; } }