[Formsess-devel] smarty-vars/functions in fs-tags
Status: Beta
Brought to you by:
mrkatana
|
From: David <da...@df...> - 2003-12-10 08:00:39
|
Hello,
I modified _glueAttributes in FormsessTag a little bit and now using
smarty vars, functions or whatever you want should be possible.
This is the modified function:
===
function glueAttributes() {
$captures = '';
$string = '';
foreach ($this->attributes as $name => $value) {
if (!$value or ($value == 'false')) {
//don't know what that means..
$format = ' %s=%s';
} elseif ($this->_fs_filter->_isSmartyVar($value)) {
//we can use a single var directly
$value = $this->smartyVariableRemoveDelimiters($value);
$format = '%s=%s';
} elseif (strpos($value, $this->_fs_filter->smarty_ldelim) !== false) {
//we need to capture the value
$captures .= $this->smartyEmbed('capture assign="fs_capture_' . $name . '"')
. $value . $this->smartyEmbed('/capture');
$value = "fs_capture_{$value}";
$format = '%s=%s';
} else {
//value is a simple string
$format = ' %s="%s"';
}
$string .= sprintf(' %s="%s"', $name, $value);
}
return $captures . $string;
}
===
That should work, however because the current version doesn't work I
didn't test it at all..
The basic thing is capturing everything that contains a smarty-delimiter
and is "more" than a simple variable.
Btw: I'm not sure if _isSmartyVar works the way it should here since it
allows whitespace before and after a var.
I did not use getAttributesNames() and getAttributeValue, accessing
$this->attributes directly is much easier.
Just tell me what you think about it..
David
ps: I don't understand the purpose of the first check, if (!$value or
($value == 'false')), why passing empty parameters unquoted to the
smarty-functions? ($format = ' %s=%s';)
|