manual/scalaGuide/main/async/ScalaComet.md

- https://github.com/garbagetown/playdocja/blob/2.2.0/documentation/2.2.0/manual/scalaGuide/main/async/ScalaComet.md
```
--- /Users/garbagetown/Desktop/2.1.5/manual/scalaGuide/main/async/ScalaComet.md	2013-09-19 22:53:02.000000000 +0900
+++ /Users/garbagetown/Desktop/2.2.0/manual/scalaGuide/main/async/ScalaComet.md	2013-09-19 10:11:22.000000000 +0900
@@ -6,16 +6,7 @@
     
 Let’s write a first proof-of-concept: an enumerator that generates `<script>` tags that each call the browser `console.log` JavaScript function:
     
-'''scala
-def comet = Action {
-  val events = Enumerator(
-     """<script>console.log('kiki')</script>""",
-     """<script>console.log('foo')</script>""",
-     """<script>console.log('bar')</script>"""
-  )
-  Ok.stream(events >>> Enumerator.eof).as(HTML)
-}
-'''
+@[manual](code/ScalaComet.scala)
 
 If you run this action from a web browser, you will see the three events logged in the browser console.
 
@@ -23,19 +14,7 @@
 
 We can write this in a better way by using `play.api.libs.iteratee.Enumeratee` that is just an adapter to transform an `Enumerator[A]` into another `Enumerator[B]`. Let’s use it to wrap standard messages into the `<script>` tags:
     
-'''scala
-import play.api.templates.Html
-
-// Transform a String message into an Html script tag
-val toCometMessage = Enumeratee.map[String] { data => 
-    Html("""<script>console.log('""" + data + """')</script>""")
-}
-
-def comet = Action {
-  val events = Enumerator("kiki", "foo", "bar")
-  Ok.stream(events >>> Enumerator.eof &> toCometMessage)
-}
-'''
+@[enumeratee](code/ScalaComet.scala)
 
 > **Tip:** Writing `events >>> Enumerator.eof &> toCometMessage` is just another way of writing `events.andThen(Enumerator.eof).through(toCometMessage)`
 
@@ -47,23 +26,13 @@
 
 Let’s just rewrite the previous example to use it:
 
-'''scala
-def comet = Action {
-  val events = Enumerator("kiki", "foo", "bar")
-  Ok.stream(events &> Comet(callback = "console.log"))
-}
-'''
+@[helper](code/ScalaComet.scala)
 
 ## The forever iframe technique
 
 The standard technique to write a Comet socket is to load an infinite chunked comet response in an HTML `iframe` and to specify a callback calling the parent frame:
 
-'''scala
-def comet = Action {
-  val events = Enumerator("kiki", "foo", "bar")
-  Ok.stream(events &> Comet(callback = "parent.cometMessage"))
-}
-'''
+@[iframe](code/ScalaComet.scala)
 
 With an HTML page like:
 

```