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

Concatenating variables in attributes #37

Open
Edo78 opened this issue Apr 1, 2016 · 3 comments
Open

Concatenating variables in attributes #37

Edo78 opened this issue Apr 1, 2016 · 3 comments
Labels

Comments

@Edo78
Copy link

Edo78 commented Apr 1, 2016

Hi,
maybe I'm doing something wrong but if I try to compile this

each related in ['a', 'b']
    img(class="bottle_"+related+".jpg", src="bottle_"+related+".jpg")

I get

<?php
if (array(
    'a',
    'b'
)):
    foreach (array(
        'a',
        'b'
    ) as $related):
        $■['related'] = $related;
?><img src="bottle_"+related+".jpg"<?php
        attr_class(add("bottle_", $related, ".jpg"));
?>/><?php
    endforeach;
endif;
?>

As you can see class and srcare compiled with different values ...
Right now I use an ugly workaround declaring variable for every concatenation I need eg. - var bottle="bottle_"+related+".jgp"but this is way far from ideal

Is it a bug or am I missing something?

@janwirth janwirth added the bug label Apr 1, 2016
@janwirth
Copy link
Collaborator

janwirth commented Apr 1, 2016

The expression inside the src attribute is not being transpiled correctly.
Looks like a bug. @ivankravchenko, do you concur?

@ivankravchenko
Copy link
Member

Sounds like original Jade code should look like:

each related in ['a', 'b']
    img(class="bottle_#{related}.jpg", src="bottle_#{related}.jpg")

Is it processed with original Jade correctly?

Anyway, jade2php should not generate incorrect output, so it's a bug.

@Edo78
Copy link
Author

Edo78 commented Apr 4, 2016

using "string #{variable}" syntax solve my problem

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

No branches or pull requests

3 participants