Answers.Body: <p>You can use these and Craft automatically adds the files in the appropriate spots.</p>
  
  <pre><code>$output = craft()-&gt;templates-&gt;includeJsFile(UrlHelper::getResourceUrl('plugin/script.js'));
  
  $output .= craft()-&gt;templates-&gt;includeCssResource(UrlHelper::getResourceUrl('plugin/styles.css'));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-28T20:42:53.547Z
Answers.LastActivityDate: 2014-07-28T20:42:53.547Z
Answers.UserDisplayName: Adam McCombs
Body: <p>I've got a variable (widget is a better word) that I want to output with accompanying CSS and/or JS. </p>
  
  <p>I'm rendering the variable (widget) with the following</p>
  
  <pre><code>return TemplateHelper::getRaw($output);
  </code></pre>
  
  <p>I realize the following exists but other than inline js/css is there a way to output the widget and include CSS/JS by only using a single variable? I want to make this as simple as possible.</p>
  
  <pre><code>&lt;script src="{{ resourceUrl('plugin/js/public.js') }}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>`</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-28T20:39:16.147Z
Comments.Text: You can give answers to your own questions in SE, Adam! If you do this, your question no longer appears as unanswered :D
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-29T15:45:22.657Z
Comments.Text: I think this is a better Q&A than the other one, but it's still a duplicate.
Comments.UserDisplayName: Matt Stein
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-29T16:21:54.267Z
Comments.Text: Good call @MattStein that would have been exactly what I needed.
Comments.UserDisplayName: Adam McCombs
Tags: <plugin-development><plugins>
Title: How to include JS and CSS resources for a plugin variable
ThreadText: # How to include JS and CSS resources for a plugin variable
  
  (Asked by: username_0 on 2014-07-28)
  
  I've got a variable (widget is a better word) that I want to output with accompanying CSS and/or JS.
  
  I'm rendering the variable (widget) with the following
  
  ```
  return TemplateHelper::getRaw($output);
  
  ```
  
  I realize the following exists but other than inline js/css is there a way to output the widget and include CSS/JS by only using a single variable? I want to make this as simple as possible.
  
  ```
  <script src="{{ resourceUrl('plugin/js/public.js') }}"></script>
  
  ```
  
  `
  
  **Tags:** plugin-development, plugins
  
  > **Comments:**
  > **username_1**: You can give answers to your own questions in SE, username_0! If you do this, your question no longer appears as unanswered :D  
  > **username_2**: I think this is a better Q&A than the other one, but it's still a duplicate.  
  > **username_0**: Good call @username_2 that would have been exactly what I needed.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-07-28. Score: 5
  
  You can use these and Craft automatically adds the files in the appropriate spots.
  
  ```
  $output = craft()->templates->includeJsFile(UrlHelper::getResourceUrl('plugin/script.js'));
  
  $output .= craft()->templates->includeCssResource(UrlHelper::getResourceUrl('plugin/styles.css'));
  
  ```
  
  
  ---
  
  