I'm looking to display/print the contents of an html or text file uploaded into assets. Not sure what parameter to access though.

Any help would be much appreciated!


You can get the file’s contents using its getContents() method:

{{ asset.getContents() }}`

That will HTML-encode the contents by default; if you need it to print unencoded, add the |raw filter. There are some big security concerns with doing that though, as the file could contain a <script> tag that facilitates an XSS attack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.