Evaluating scripts within Pillar

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Evaluating scripts within Pillar

abergel
Hi!

I am now digging into Pillar. My goal is to be able to insert Roassal script and having it executed.
Scripts provided within [[[ ]]] may be evaluated using the variable ‘eval=true’. Here is an example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '100 factorial =
[[[eval=true
stream nextPutAll: 100 factorial asString
]]]';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

‘stream’ is a hardcoded variable name which represents the stream on which you have to write your result. What you write in stream is pillar-friendly. This means you can write something like: 

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '100 factorial =
[[[eval=true
stream nextPutAll: ''""'', 100 factorial asString, ''""''
]]]';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I have tried to insert some Roassal visualization, and it works pretty well.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '
!!Example of a factorial
50 factorial =
[[[eval=true
stream nextPutAll: ''""'', 100 factorial asString, ''""''.
]]]

!!Some Roassal visualizations
Here is a small Mondrian example
[[[eval=true

b := RTMondrian new.
b nodes: (1 to: 100).
b layout grid.
b build.

aView := b view.
RTHTML5Exporter new insert: aView named: ''Roassal test'' inPillarStream: stream
]]]

Another example with Grapher this time:
[[[eval=true
b := RTGrapher new.
b extent: 300 @ 200.

ds := RTStackedDataSet new.
ds interaction popupText.
ds barShape width: 10.
ds points: #(4 5 1 -2 5 6).
b add: ds.
"b axisX noLabel; noTick.
"

b build.

RTHTML5Exporter new insert: b view named: ''A Graph'' inPillarStream: stream
]]]

';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Pillar is very well done! Congrats to the authors!

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



Reply | Threaded
Open this post in threaded view
|

Re: Evaluating scripts within Pillar

stepharo
Nice :)
We were thinking with damien that such

[[[ line

is a nice way to extend based on annotation.
Stef


Le 24/2/15 23:11, Alexandre Bergel a écrit :
Hi!

I am now digging into Pillar. My goal is to be able to insert Roassal script and having it executed.
Scripts provided within [[[ ]]] may be evaluated using the variable ‘eval=true’. Here is an example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '100 factorial =
[[[eval=true
stream nextPutAll: 100 factorial asString
]]]';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

‘stream’ is a hardcoded variable name which represents the stream on which you have to write your result. What you write in stream is pillar-friendly. This means you can write something like: 

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '100 factorial =
[[[eval=true
stream nextPutAll: ''""'', 100 factorial asString, ''""''
]]]';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

I have tried to insert some Roassal visualization, and it works pretty well.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PRHTMLWriter defaultConfigurations anyOne
    inputString: '
!!Example of a factorial
50 factorial =
[[[eval=true
stream nextPutAll: ''""'', 100 factorial asString, ''""''.
]]]

!!Some Roassal visualizations
Here is a small Mondrian example
[[[eval=true

b := RTMondrian new.
b nodes: (1 to: 100).
b layout grid.
b build.

aView := b view.
RTHTML5Exporter new insert: aView named: ''Roassal test'' inPillarStream: stream
]]]

Another example with Grapher this time:
[[[eval=true
b := RTGrapher new.
b extent: 300 @ 200.

ds := RTStackedDataSet new.
ds interaction popupText.
ds barShape width: 10.
ds points: #(4 5 1 -2 5 6).
b add: ds.
"b axisX noLabel; noTick.
"

b build.

RTHTML5Exporter new insert: b view named: ''A Graph'' inPillarStream: stream
]]]

';
    outputFile: 'myFirstPillarExport.html' asFileReference;
    export
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Pillar is very well done! Congrats to the authors!

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.