Take a look at this line:
'src' => array(OPT_PARAM_REQUIRED, OPT_PARAM_STRING),
The second constant defines the requested type. Here is the full description:
http://www.invenzzia.org/docs/opt-en/extending.instructions.parameters.htmlFor this particular example, you have to choose between
OPT_PARAM_EXPRESSION and
OPT_PARAM_ASSIGN_EXPR. The first one does not allow to use the assignment operator, like
$a is 5, the second one - allows.
This class is executed only during the template compilation and during the execution, the produced PHP code works, so you have to change also the following line:
$this->compiler->out(' echo \'<script language="javascript" type="text/javascript" src="'.$params['src'].'"></script>\'; ');
If you changed the parameter type and made
{js_include src="$myvar"}, this will be compiled into:
echo '<script language="javascript" type="text/javascript" src="$this->data['myvar']"></script>';
Obviously, it's not even a valid PHP code! You must teach the instruction, how to enclose the expression in the quotes:
$this->compiler->out(' echo \'<script language="javascript" type="text/javascript" src="\'.'.$params['src'].'.\'"></script>\'; ');
But remember that if you have a statically defined file, you must also enclose it in the quotes in the template:
{js_include src="'some_file.js'"}
I know it's a disadvantage, but in OPT 1.x there was little I could do. The expression is expression, like in PHP - here you also can't write very long texts without quotes and OPT must know where the attribute value ends (which gives you the double quote). In OPT 2.0 and XML, this was solved with namespaces:
<opt:js_include str:src="some_file.js" /> or <opt:js_include src="$myvar" />
Of course you can always write <opt:js_include src="'some_file.js'" />