---
title: "Wysiwyg Editing of Play! Framework Templates with the Aloha Editor"
date: 2013-05-03T21:08:55+00:00
author: "poornerd"
tags: ["aloha-editor", "wysiwyg"]
canonical: https://www.poornerd.com/2013/05/03/wysiwyg-editing-of-play-framework-templates-with-the-aloha-editor/
source: Raw Markdown twin of the HTML article; content is the original source.
---
[<img class="alignleft size-medium wp-image-301" alt="aloha-saves" src="https://www.poornerd.com/wp-content/uploads/2013/05/aloha-saves-300x166.jpg" width="300" height="166" srcset="https://www.poornerd.com/wp-content/uploads/2013/05/aloha-saves-300x166.jpg 300w, https://www.poornerd.com/wp-content/uploads/2013/05/aloha-saves.jpg 800w" sizes="(max-width: 300px) 100vw, 300px" />](https://www.poornerd.com/wp-content/uploads/2013/05/aloha-saves.jpg)Ok, so it is only partial editing, but still this is an interesting step in the &#8220;**no CMS**&#8221; direction. What I have done is modified the example code which I posted on <a href="https://github.com/poornerd/play-aloha" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">github</a> last week for inline editing of HTML5 elements with the <a href="http://www.aloha-editor.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.aloha-editor.org');" target="_blank">Aloha WYSIWYG Editor</a> to actually save the new content back in to the Scala Template.

I find this useful for allowing non-techie colleagues to edit and optimize text and wordings in more content oriented templates. Of course it does directly modify the source, so in the case of a live website you would want to do this in the development environment and then **commit, push, deploy** the new version &#8211; hence &#8220;**no CMS**&#8220;.

In my example I have limited the frontend code to a block in the footer template. It is only rendered into the page if the following value is set to true in the `application.conf`:

<pre class="brush: plain; title: ; notranslate" title="">play-aloha.admin=true</pre>

One of the non-elegant parts of the code is deciding which template file to look for the HTML to replace. Right now it is hard coded. I supposed the most pragmatic way would be to create a hashtable mapping URL&#8217;s to filenames.

Here you can see the changed HTML in the scala template:

[<img class="alignleft size-full wp-image-302" alt="git-diff" src="https://www.poornerd.com/wp-content/uploads/2013/05/git-diff.png" width="700" height="228" srcset="https://www.poornerd.com/wp-content/uploads/2013/05/git-diff.png 700w, https://www.poornerd.com/wp-content/uploads/2013/05/git-diff-300x97.png 300w" sizes="(max-width: 700px) 100vw, 700px" />](https://www.poornerd.com/wp-content/uploads/2013/05/git-diff.png)

&nbsp;

The code is in github here: <a href="https://github.com/poornerd/play-aloha" onclick="javascript:pageTracker._trackPageview('/outbound/article/github.com');" target="_blank">https://github.com/poornerd/play-aloha</a>
