Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sjferwerda
Last active December 14, 2015 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjferwerda/5154271 to your computer and use it in GitHub Desktop.
Save sjferwerda/5154271 to your computer and use it in GitHub Desktop.
Iframe shortcode parser for Lightning
<dti:story:element:exist field="WebText">
<script language="cache" runat="server">
set storyText = ##class(dt.cms.support.Rules).extractStoryElement("WebText",gStory,0)
</script>
<dti:else>
<script language="cache" runat="server">
set storyText = ##class(dt.cms.support.Rules).extractStoryElement("Text",gStory,0)
</script>
</dti:story:element:exist>
<script language="cache" runat="server">
// parse iframe shortcodes if they exist
set iframeCount = $LENGTH(storyText,"[iframe")
if (iframeCount >= 1) {
set pos = 1
set val = ""
FOR i=1:1:iframeCount {
set iframeMatch = $LOCATE(storyText, "\[iframe (.*?)\](.*?)", pos, pos, val)
set params = $REPLACE($REPLACE(val,"[iframe ", ""),"]","")
set storyText = $REPLACE(storyText,val,"<iframe "_params_" class=""iframe-default""></iframe>")
}
}
write storyText
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment