Answers.Body: <p>You can get the file’s contents using its <code>getContents()</code> method:</p>
  <pre><code>{{ asset.getContents() }}`
  </code></pre>
  <p>That will HTML-encode the contents by default; if you need it to print unencoded, add the <code>|raw</code> filter. There are some big security concerns with doing that though, as the file could contain a <code>&lt;script&gt;</code> tag that facilitates an XSS attack.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-06T13:50:28.653Z
Answers.LastActivityDate: 2021-06-06T13:50:28.653Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I'm looking to display/print the contents of an html or text file uploaded into assets. Not sure what parameter to access though.</p>
  <p>Any help would be much appreciated!</p>
  
Tags: <assets>
Title: How do I get the content from a text or html file in an assets directory to be displayed?
ThreadText: # How do I get the content from a text or html file in an assets directory to be displayed?
  
  (Asked by: username_0 on 2021-06-06)
  
  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!
  
  **Tags:** assets
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-06. Score: 1
  
  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.
  
  
  ---
  
  