n:macro always behaving as “inner”

3 years ago

amik
Member | 124
+
+1
-

Hi, is it possible to write an n:macro always wrapping inner content of the element like this?

<div class="foo bar" n:upper>
    upper
</div>

should compile into

<div class="foo bar">
    <?php ob_start(); ?>
    upper
    <?php echo strtoupper(ob_get_clean()); ?>
</div>

I don't want to write n:inner-upper always, and I don't want to allow tag- and default variants.

Note: I'm not really building a macro for uppering content, I'm building a macro to replace element's inner content with user-editable content, I've written this example just to simply explain stuff.

Last edited by amik (2015-10-05 14:55)

3 years ago

David Grudl
Nette Core | 6787
+
0
-

Currently it is not possible. n:snippet works this way, but it is done as hack.

3 years ago

amik
Member | 124
+
+1
-

@DavidGrudl would it be useful if I implement and pullrequest it, or it is not possible intentionally?

3 years ago

David Grudl
Nette Core | 6787
+
+1
-

Yes, it would be useful.

3 years ago

amik
Member | 124
+
0
-

OK, my proposed solution: https://github.com/…atte/pull/85