bstrahija / assets-ci

Simple assets library for CodeIgniter. Ability to combine, minify and use the Less syntax.
http://creolab.hr
112 stars 31 forks source link

Allow user to specify whether to echo JS and CSS tags #32

Closed dangmai closed 11 years ago

dangmai commented 11 years ago

Hi,

I noticed that _generate_tags() has the option to either return or echo tags, but js(), js_group(), css() and css_group() don't, so I added the ability to specify whether to echo tags for those functions. I find this pretty handy when I don't directly use Assets in my views.

Thanks for the awesome project!

bstrahija commented 11 years ago

All I can see is you added the $echo parameter everywhere, but don't actually use it anywhere :)

Anyway, I'm planning to remove the echo completely so you would have to do:

<?php echo Assets::js(array('jquery.js', 'script.js)); ?>

Meaning the value would always be returned. Kinda makes more sense than adding an additional parameter.

dangmai commented 11 years ago

Well, all the methods that I modify return what _generate_tags returns, and you already let generate_tags either return the tags or echo the tags based on the $echo param, so I simply add the option to those methods. I do use these options in my project (not directly in the Views, hence why I don't want them to echo the tags).

By the way, I think that removing echo completely is the way to go, my commit is just a workaround that I use right now, so feel free to close the PR if you're planning to remove echo.

bstrahija commented 11 years ago

You're right. I seem to spend to little time on this project :) I'll probably just remove the echo and use return. Thanks for the contribution anyway ;)