Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
feature: macro n:attr expands arrays #158
When the first and only argument to n:attr macro is an array, expand it.
I opened another PR solving the same thing by adding a new macro here: #157
array ( 'content' => 'width=device-width, initial-scale=1', 'name' => 'viewport', 'http-equiv' => NULL, 'scheme' => NULL, )
The developer wants to achieve this HTML output:
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta 0="content:width=device-width, initial-scale=1 name:viewport">
The developer is currently forced to use workarounds, like:
'$_tmp = %node.array; echo LR\Filters::htmlAttributes( isset($_tmp) && is_array($_tmp) && count($_tmp) === 1 ? $_tmp : $_tmp);'
After the proposed change, the developer can use
with an expected result.
<tag n:attr="['foo' => 'bar']">
<meta n:foreach="$metas as $meta" n:attr="$meta">
This approach is however very useful for many other cases during output generation.