Good day all
note: Play! Framework newbie here.
I am trying to familairze myself using scala templates for a project, but cannot quite seem to get it right, nor do the examples found online always work correctly.
Problem:
I have to have searched for small solutions for a problem, and frequently encounter syntactical errors or the like.
I decided to search for some comprehensive guide to building Scala templates used as views, but found only fragments and pieces of code that may help.
Documentation Provided:
Play Scala Documentation
Play provided examples:
Examples in Java and Scala
Variables:
Declaring variables
Declaring Variable 2
Displaying Data:
Displaying data using functions
Display Items in alternating rows table with indicies
Using blocks
Displaying Block Scala variables in html see the use of { and }
Passing Data / Objects:
Passing objects between views and controllers
Further Reading:
Play Google Groups thread
Question:
note: I am asking this only since I have no idea how to proceed
Is there any comprehensive guide for building Scala templates. Documented to such a degree as one would find for Play! Framework?
TL;DR Where did you learn / discover how to create simple to complex Play! Scala templates?
Here you have pack of examples and Play seed projects:
https://playframework.com/download#examples
You should look for a blogposts about play templates:
http://mariussoutier.com/blog/2012/04/27/play-framework-2-0-templates-part-1-parameters/
You should read play documentation. It isn't perfect, but very helpful.
https://www.playframework.com/documentation/2.6.x/ScalaTemplates
I would say the templates are somehow intuitive. You write html and when you want to do some scala you should start the expression with an #.
When I find myself struggling with the syntax I just google "scala play twirl map" if I want to know the syntax for the .map (twirl is the real name of the template engine)
Besides that, the documentation under https://www.playframework.com/documentation/2.6.x/ScalaTemplates should be the best resource
Related
My team works with Scala.js and I wanna use Material-UI. But those two's code types look very different. Most of the examples in Material-UI seem to be based on regular Javascript.
I've tried to search about that, but the information is very limited, so I couldn't get any useful information. Is there anyone using Material-UI with Scala.js?
When using most JS libraries from Scala.js, you need what is called a "facade" -- a strongly-typed Scala wrapper that describes how to use the weakly-typed JavaScript library.
There appear to be several Material UI facades, but most of them look a bit half-baked. I'd guess that the most mature is the one in Chandu's scalajs-react-components project -- in general, Chandu has done more with React in Scala.js than most folks. The general top-level page for the project can be found here.
I am looking for a good template based run-time code generation library in Scala. I need this for my ERP system to generate artifacts (html, and other code files)
Can any please point me in right direction?
You should take a look at Scalate. It has multiple syntax choices and if you use SSP you can easily create templates for text other than HTML as well.
If your app is web-based, Play has a templating system for generating the output pages.
Trying to learn lift, and i'm looking for a somehow bigger example than HelloWorld (something like spring pet-clinic).
Especially i'm looking at advanced templating in designer friendly manner (as less code in snippets as possible).
I tried to look at example Lift apps https://github.com/lift/examples
But they heavily mix html in their snippets https://github.com/lift/examples/blob/master/nuggets/skittr/src/main/scala/com/skittr/snippet/UserMgt.scala
So can anyone link me to a source of real world app that uses designer-friendly templating?
Hmmm. My hobbie project partially corresponds to what you ask, I think.) https://github.com/vn971/roboCup
It's not all good, I started it when only learning Scala and I see now that it has poor decision choises in some places. But, for example, you can see code-free templates here:
https://github.com/vn971/roboCup/blob/master/src/main/webapp/swiss.html
Ajax bindings can be seen here:
https://github.com/vn971/roboCup/blob/master/src/main/webapp/admin.html
It unfortunately uses html in the code somewhere, too. It's also very little, uses actors (both lift's and akka), has no database at all (only the state of the tournament matters and it's not persisted).
try lift in action book , there is a build of a big web app almost step by step and the project is also on github so you can download it also from there
Hey, I have been searching all over for a solution to injecting into action filters. I have found a few solutions but they were implemented with an older version of ninject/mvc. Has anyone found a simple solution to this problem? I have been blocked for a day trying to get a clean implementation.
I have looked at this solution but a lot of the functions he uses are deprecated in Ninject.
Ninjet.Web.Mvc has support for this and the source code comes with a sample application that has filter injection. See https://github.com/ninject/ninject.web.mvc. The only thing that you have to do is adding a porperty with the Inject attribute to your action filter.
MVC3 has even better support see http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/#more-2004
I want to start a project using the Scala language. While searching for web frameworks I've found Lift. However, it is not what I was looking for: a web framework that has complete separation of HTML and code. Lift does have some nice features (and a learning curve) but we need to have complete separation of HTML and code. I was hoping to find something like Wicket, Tapestry or Barracuda for the Scala language.
Although it is nice to be able to reuse html templates, it is more important to us to have the HTML templates work as a "static application" mockup. In Tapestry we can just put links in the static templates and use that to have static navigation and a sort of prototype of the application.
So, do you know of any other web framework that is easy to work with the Scala language?
Thanks,
Luis
Here it is I can understand why you might want it pure Scala, but you haven't stated that's necessary, and with the techniques defined within the blog post, and there is another blog which also helps, you should be able to get it close enough to what you desire.
Tapestry 5 has many similarities with Wicket and works very well with Scala. I haven't tried it myself, but Francois Armand has being doing it for some time and he's writing about in in his blog.
Try Context. It is a component based framework written in Java but I have used it with Scala without much difficulties.
Context uses XSL as templating language which forces a sharp separation between logical presentation (DOM-tree) and actual presentation (HTML/CSS/JS).
You can even, with little effort, create prototypes and mocked views by faking the DOM-tree and trying invidual components in different combinations.