kohana-assets icon indicating copy to clipboard operation
kohana-assets copied to clipboard

Request: Alternative to ::get() that returns <style></style> tags instead of <link> (similiarly for JS)

Open alanhogan opened this issue 14 years ago • 5 comments

Would be nice to have something like get_inline() or the like. Note that HTML should be escaped between these tags.

Use case — for when paths are not resolvable, e.g. server-side PDF generation when additional HTTP requests from the PDF generator are not desirable.

alanhogan avatar Jul 26 '10 20:07 alanhogan

This would also come in handy for sending emails.

dtb avatar Jul 26 '10 20:07 dtb

I think the proper solution here is to have the 2 different layouts handle the way the assets are included. The website layout would wrap everything with HTML::style() or HTML::script(), the pdf layout would wrap in

I might need to change the assets config a little to be more informative but I think it would be the cleanest solution

zeelot avatar Jul 26 '10 20:07 zeelot

I don’t like that very much as an API. Just think, how many people would just do a '' and forget to html::chars things? Then when a few CSS rules are broken, no one catches it for months… the assets module should handle this IMO.

alanhogan avatar Jul 26 '10 20:07 alanhogan

it could also be put into the template as to allow mustache to automatically escape the contents

<style>
    {{#styles}}{{style}}{{/styles}}
</style>

I will see what I can do though

zeelot avatar Jul 26 '10 20:07 zeelot

If you're suggesting what Alan said (<style><?= file_get_contents($x)</style> in the template), I have to agree that that's very ugly.

dtb avatar Jul 26 '10 20:07 dtb