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

How to write inline PHP without echo in the result? #91

Open
pshemek opened this issue Jan 19, 2016 · 3 comments
Open

How to write inline PHP without echo in the result? #91

pshemek opened this issue Jan 19, 2016 · 3 comments

Comments

@pshemek
Copy link

pshemek commented Jan 19, 2016

Hello,

I would like to end with the following line in the PHP file:

<article class="<?php post_class(); ?>">

However, when I write in Haml:

%article(class="<?php post_class() ?>")

The result is

<article class="<?php echo '<?'; ?>php post_class() ?>">

I know I could use something like class="#{my_get_post_class()}" but I'd like to utilize the function which itself echoes the string so I don't need an additional echo before in PHP code.

How to do that? (MtHaml 1.8, enableDynamicAttributes: false)

@Boorj
Copy link

Boorj commented Jan 21, 2016

can you make a twig extension?

@pshemek
Copy link
Author

pshemek commented Jan 21, 2016

Well, I'd prefer not to do it. Probably, if there's no better option, I will end with some string replacement on the output (working with grunt-haml-php)

@Boorj
Copy link

Boorj commented Jan 22, 2016

actually, mthaml is nice because it can process twig injections, not sure about grunt-haml-php.
And also you can check out Php filter in mthaml https://github.com/arnaud-lb/MtHaml/blob/master/lib/MtHaml/Filter/Php.php
And.. have you tried %article(class="#{<?php ... ?>}")?

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