Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attribute values should be expressions #18

Closed
Nowaker opened this issue Jun 24, 2011 · 4 comments
Closed

attribute values should be expressions #18

Nowaker opened this issue Jun 24, 2011 · 4 comments
Assignees

Comments

@Nowaker
Copy link
Collaborator

Nowaker commented Jun 24, 2011

<img>
    <lsp:attribute name="alt" value="$user.name" />
    <lsp:attribute name="src" value="$user.profile.avatar" />
</img>

I'm quite surprised to see <img alt="$user.name" src="$user.profile.avatar" /> in output.

I see no point in writing <img><lsp:attribute name="alt" value="something"/></img>. lsp:attribute make sens when expressions are allowed in value attribute.

I consider it critical.

@Nowaker
Copy link
Collaborator Author

Nowaker commented Jun 25, 2011

Thanks to debugger I digged into the source code and found out it will do the stuff:

<img>
    <lsp:attribute name="alt" value="{$user.name}" />
    <lsp:attribute name="src" value="{$user.profile.avatar}" />
</img>

There should be an example in documentation.

However, I would never think it could be this way. It's inconsistent to the rest of LSP. in lsp:value-of[select] I just write $var - why do I have to write {$var} in [lsp:attribute[value]?

@Nowaker
Copy link
Collaborator Author

Nowaker commented Jun 25, 2011

Documented the feature via unit test. 39d3a36

@ghost ghost assigned mikaelstaldal Jun 25, 2011
@mikaelstaldal
Copy link
Owner

You don't have to use <lsp:attribute> at all in this case, just use this instead:
<img alt="{$user.name}" src="{$user.profile.avatar}"/>

<lsp:attribute> is only necessary if the name of the attribute is dynamic, or when used in combination with <lsp:element>.

(This is inspired from XSLT.)

@Nowaker
Copy link
Collaborator Author

Nowaker commented Jun 25, 2011

I see. Looks good. BTW - I also tried <img lsp:alt="{$user.name} />" but didn't think of the simplest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants