Teapot and Mustache in Pharo 6?

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

Teapot and Mustache in Pharo 6?

Hannes Hirzel
Hello

The TeaPot documentation [1] references Mustache [2] in the section

      4.1. Response Transformers [3]

There is an example for a JSON transformation but none for Mustache.

Where do I find some information how to use Mustache together with Teapot?

Regards
Hannes




[1]
https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Teapot/Teapot.html

[2] https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Mustache/Mustache.html


[3] The responsibility of a response transformer is to convert the
output of the action block to HTML and to set the content-type of the
response. Some response transformers require external packages (e.g.,
NeoJSON, STON, Mustache).

[4] Adapted example

TLWebserver teapot   GET: '/jsonlist' -> #(1 2 3 4); output: #json.

Reply | Threaded
Open this post in threaded view
|

Re: Teapot and Mustache in Pharo 6?

Attila Magyar
This post was updated on .
Hi Hannes,

You can find some examples in the Enterprise Pharo book (http://files.pharo.org/books/enterprise-pharo/).

Teapot on
   GET: '/greet' -> {'phrase' -> 'Hello'. 'name' -> 'World'};
   output: (TeaOutput mustacheHtml: '<html>{{phrase}} {{name}}!</html>');
   start.

The {'phrase' -> 'Hello'. 'name' -> 'World'} serves as a model for the template engine. Imagine that this was returned by some domain logic.

Anyway my preferred way of using Teapot is to use it as a REST (-like) backend and consume/produce JSON (or whatever) objects, instead of generating HTMLS on the server side via Mustache.

Attila
Reply | Threaded
Open this post in threaded view
|

Re: Teapot and Mustache in Pharo 6?

Stephane Ducasse-3
In reply to this post by Hannes Hirzel
You have a also mustaside a bridge between mustache and seaside.


On Mon, Aug 21, 2017 at 5:52 PM, H. Hirzel <[hidden email]> wrote:

> Hello
>
> The TeaPot documentation [1] references Mustache [2] in the section
>
>       4.1. Response Transformers [3]
>
> There is an example for a JSON transformation but none for Mustache.
>
> Where do I find some information how to use Mustache together with Teapot?
>
> Regards
> Hannes
>
>
>
>
> [1]
> https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Teapot/Teapot.html
>
> [2] https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Mustache/Mustache.html
>
>
> [3] The responsibility of a response transformer is to convert the
> output of the action block to HTML and to set the content-type of the
> response. Some response transformers require external packages (e.g.,
> NeoJSON, STON, Mustache).
>
> [4] Adapted example
>
> TLWebserver teapot      GET: '/jsonlist' -> #(1 2 3 4); output: #json.
>

Reply | Threaded
Open this post in threaded view
|

Re: Teapot and Mustache in Pharo 6?

Offray Vladimir Luna Cárdenas-2
In reply to this post by Hannes Hirzel
Hi,

On the Teapot + Mustache integration, Hannes, you may want to see my early prototype:

http://smalltalkhub.com/#!/~Offray/Brea

At some point, it will contain distributed wiki, backed by Fossil, now that we're thinking in empower community driven wiki like documentation.

Offray

El 21 de agosto de 2017 10:52:47 GMT-05:00, "H. Hirzel" <[hidden email]> escribió:
Hello

The TeaPot documentation [1] references Mustache [2] in the section

4.1. Response Transformers [3]

There is an example for a JSON transformation but none for Mustache.

Where do I find some information how to use Mustache together with Teapot?

Regards
Hannes




[1]
https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Teapot/Teapot.html

[2] https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Mustache/Mustache.html


[3] The responsibility of a response transformer is to convert the
output of the action block to HTML and to set the content-type of the
response. Some response transformers require external packages (e.g.,
NeoJSON, STON, Mustache).

[4] Adapted example

TLWebserver teapot GET: '/jsonlist' -> #(1 2 3 4); output: #json.


--
Enviado desde mi dispositivo Android con K-9 Mail. Por favor, disculpa mi brevedad.