cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript - Dynamic content

drozes
Champ in-the-making
Champ in-the-making
Hi guys;

So I've written a webscript which grabs a file from the Content Repo.
It than parses the file's content and looks for special html tags than indicates ServerSide code.

My webscript will execute the code within the special html tags as if it was serverside code.  This is simple grabbing the code and running eval on it, than replacing the content.

The issue is, I am unsure on how to exactly execute the code within the tags fully.  Currently it just executes and the code and replace the content with the results of the execution, which sounds successful but in practice is not.  For example if you want to reference an webscript object that doesn't have any type fo output, it'll print out the object class@memory.

Do webscript have a built in execution, that allows content to be executed as if it was straight in the webscript?
Or will I have to extend my webscript into a language compiling tool?


-Reasoning behind this need.  I have a file in my document repo that references CSS files.  I need the app context. So I use a line like  ' src="<?alf url.context; ?>/css/mycss.css" '.   My webscript currently works well for this case, but I'd like to have a more full approach on this.
2 REPLIES 2

ddraper
World-Class Innovator
World-Class Innovator
Just a quick check…

If you only want to get the application context then you can use the following in your WebScript template:

${url.context}

So if you used this in a WebScript in Share it would return "/share". This information (and info on other useful model objects can be found here: http://wiki.alfresco.com/wiki/Web_Scripts#Alfresco_RESTful_API_Reference).

Regards,
Dave

drozes
Champ in-the-making
Champ in-the-making
Thanks for your suggestion, but it's a bit off from what I am attempting to do.


I want to be able to use ANY webscript call from REPO content.

So, if you have a site and in that site's document library you have a file called 'test.html'.  You have a webscript that's gonna display that 'test.html'.  I want to be able to include webscript calls in NON-Webscript files.

Hoping there is some type of command that streams content as if it was a webscript.

There is <@streamasset asset=asset/> in the WQS  -  Hoping there is something of that natural but also executes the content.