alexluke / grunt-haml-php

Process HAML templates using MtHaml, a PHP port of Haml.
MIT License
9 stars 8 forks source link

php in html-attributes require mthaml in runtime #6

Closed javoire closed 9 years ago

javoire commented 10 years ago

According to MtHaml docs (https://github.com/arnaud-lb/MtHaml), this:

%ul#users
  - foreach($users as $user)
    %li.user
      = $user->getName()
      Email: #{$user->getEmail()}
      %a(href=$user->getUrl()) Home page

Is supposed to become this:

<ul id="users">
  <?php foreach($users as $user) { ?>
    <li class="user">
      <?php echo $user->getName(); ?>
      Email: <?php echo $user->getEmail(); ?>
      <a href="<?php echo $user->getUrl(); ?>">Home page</a>
    </li>
  <?php } ?>
</ul>

However, using grunt-haml-php, I get this:

<ul id="users">
  <?php foreach($users as $user) { ?>
    <li class="user">
      <?php echo $user->getName(); ?>
      Email: <?php echo $user->getEmail(); ?>
      <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', ($user->getUrl()))), 'html5', 'UTF-8'); ?>>Home page</a>
    </li>
  <?php } ?>
</ul>

The href attribute on the a-tag requires MtHaml at runtime. I don't if this is what you're referring to here #3.

Is there a possibilty to change this behaviour? I'm sooo close now to not having to use regular ugly php and html so I'd be so thrilled if was possible.

Cheers Jonatan

javoire commented 10 years ago

Yeah I think this is might be a solution https://github.com/scil/MtHamlMore#extra-feature-2--reduce-runtime, which is also mentioned i #3

ezekg commented 9 years ago

@alexluke @javoire I realize this is old, but I recently committed a pull request that adds an option to disable this: https://github.com/arnaud-lb/MtHaml/commit/1eddd2c8a9b9d598009cc6b397981d8b57d73ef2

You can see how I implemented it into a Guard plugin here.

esad commented 9 years ago

@ezekg Thanks for this patch, I've just made a PR for grunt-haml-php to accept and pass enableDynamicAttributes option to the new version of MtHaml

@alexluke Do you mind giving it a look?

alexluke commented 9 years ago

Thanks everyone, 0.4.1 is now available on npm with this option.