Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Sep 6, 2021
1 parent bfcc066 commit f465547
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions doc/source/main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,19 @@ To render plain strings:
from turbo_response import TurboFrame, TurboStream, Action
# returns <turbo-stream action="replace" target="msg><template>OK</template></turbo-stream>
# returns <turbo-stream action="replace" target="msg"><template>OK</template></turbo-stream>
TurboStream("msg").replace.render("OK")
# returns <turbo-stream action="replace" targets=".msg"><template>OK</template></turbo-stream>
TurboStream(".msg", is_multiple=True).replace.render("OK")
# set action dynamically
TurboStream("msg").action(Action.REPLACE).render("OK")
# returns <turbo-stream action="remove" target="msg><template></template></turbo-stream>
# returns <turbo-stream action="remove" target="msg"><template></template></turbo-stream>
TurboStream("msg").remove.render()
# returns <turbo-frame id="msg>OK</turbo-frame>
# returns <turbo-frame id="msg">OK</turbo-frame>
TurboFrame("msg").render("OK")
You can also render templates:
Expand All @@ -99,6 +102,8 @@ You can also render templates:
TurboStream("msg").replace.template("msg.html", {"msg": "hello"}).render()
TurboStream(".msg", is_multiple=True).replace.template("msg.html", {"msg": "hello"}).render()
TurboFrame("msg").template("msg.html", {"msg": "hello"}).render()
You can also return an *HTTPResponse* subclass. The content type *text/html; turbo-stream;* will be added to turbo stream responses.
Expand Down

0 comments on commit f465547

Please sign in to comment.