pstanton
pstanton

Reputation: 36640

Tapestry 4.1 - using a Script component with an external js

Is it possible to use a @Script component to render a script tag pointing to a js file hosted on a different server?

Basically, I need to inject a script tag such as:

<script src="http://otherserver.com/script.js"></script>

but I need to have it render in the head, or at least before other tapestry scripts are rendered.

Thanks, Paul.

Upvotes: 1

Views: 850

Answers (2)

Civil Disobedient
Civil Disobedient

Reputation: 1547

Assuming you're using a Shell component to wrap all your other files:

<html jwcid="@Shell" delegate="ognl:new org.apache.tapestry.components.BlockRenderer(getComponent('scriptBlock'))">

  <span jwcid="scriptBlock@Block">
    <script src="http://otherserver.com/script.js"></script>
  </span>

  ...

</html>

Upvotes: 1

Andreas Andreou
Andreas Andreou

Reputation: 1332

If you're using the Shell component , it's easy:

Shell.get(cycle).includeAdditionalContent( myHtmlForHead );

Or write a simple component that does that and reuse it in your templates.

Upvotes: 1

Related Questions