Search code examples
scalalift

How do I simply embed HTML into a layout/template in Lift?


I am just starting out with Scala and Lift and I apologize ahead of time about this pretty basic question but how do I "import" or rather embed HTML file into a layout/template?

Basically I have a bunch of layouts and each of them has hard coded footer. I want to extract footer into a separate HTML and then reference it back in all layout files.


Solution

  • Check out the "starting" template for Lift: https://github.com/lift/lift_25_sbt/

    In Lift Basic https://github.com/lift/lift_25_sbt/tree/master/scala_210/lift_basic you can see an example of a footer that can be put around many other HTML-s: https://github.com/lift/lift_25_sbt/blob/master/scala_210/lift_basic/src/main/webapp/templates-hidden/default.html

    To use this footer, you access it like in https://github.com/lift/lift_25_sbt/blob/master/scala_210/lift_basic/src/main/webapp/index.html :

    <div id="main" class="lift:surround?with=default;at=content">
    

    Another link to read about this: http://simply.liftweb.net/index-3.3.html#toc-Subsection-3.3.3

    BTW, starting with the lift_basic github template is a good idea anyway.