Coming from a background in PHP, I am used to the idea that I can simply embed server-side scripts into my HTML pages. Searching online, I haven't been able to find a simple echo <h1>Hello World</h1>;
equivalent in Scala besides using a web framework like Lift. Can I do this with Scala?
PHP is an exception in being a language designed to be embedded in an HTML page. Apache has mod_php
to do this for you. Scala, like many other languages, requires you to start up a web server to respond to requests and render HTML. You can use frameworks like Lift or Play, or you can make a Servlet-based app and deploy it into any Servlet container.
You could set up an Apache server to run CGI scripts and then insert a .scala file to be run by the scala
command - but it would be incredibly slow as it would have to start up the Java VM every time. I wouldn't recommend that for anything other than scratching a mental itch.
See Scalate and PlayFramework
Scalate Scaml is very close to what you want
Scalate supports the following template formats