Error when trying to assign a value to a variable with kind="trusted+resource_uri"

79 views
Skip to first unread message

Sameer Shastri

unread,
Aug 10, 2016, 2:23:45 PM8/10/16
to Closure Templates Discuss
Hi,

I am currently trying to load a script whose src url comes from injected data, however with the following code I get the error "Specified content kind has no associated end context".

{let $srcUrl kind="trusted_resource_uri"}
       ($ij.config?['SRC_URL'])
{/let}
<script type="text/javascript" src="{$srcUrl}" async defer></script>

If I try changing the kind of srcUrl to url then I get the following output <script type="text/javascript" src="about:invalid#zSoyz" async defer>

Can you please help me figure out what I am doing wrong?

Cheers,
Sam



Mike Samuel

unread,
Aug 10, 2016, 2:25:30 PM8/10/16
to closure-temp...@googlegroups.com

What is the type of ij.config.SRC_URI?


--

---
You received this message because you are subscribed to the Google Groups "Closure Templates Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johannes Nel

unread,
Aug 10, 2016, 2:47:47 PM8/10/16
to closure-temp...@googlegroups.com
its a url to a js file we want to write into a script tag's src attribute.
it comes through product configuration (which is injected obviously)

To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-discuss+unsubsc...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mike Samuel

unread,
Aug 10, 2016, 5:57:02 PM8/10/16
to closure-temp...@googlegroups.com

Is it an instance of java.net.URI or of String or of TrustedResourceUrl or of SanitizedContent?

Johannes Nel

unread,
Aug 10, 2016, 6:00:57 PM8/10/16
to closure-temp...@googlegroups.com
String.


Johannes Nel

unread,
Aug 10, 2016, 6:02:21 PM8/10/16
to closure-temp...@googlegroups.com
I assume that using the let statement with a kind as a cast of sorts is what is failing here.
Is there a way to cast a string to sanitized content in soy without writing our own plugin?

Mike Samuel

unread,
Aug 10, 2016, 6:51:54 PM8/10/16
to closure-temp...@googlegroups.com

http://static.javadoc.io/com.google.common.html.types/types/1.0.0/com/google/common/html/types/TrustedResourceUrls.html or the builder class in that same package let you create values that you can use in your ij map.


To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages