Question

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.

Was it helpful?

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.

OTHER TIPS

If you are just looking to pull in an HTML file, like a footer, you can use the embed snippet, as specified here.

So, if you have a file in the root of your webapp named footer.html, you can embed it with this code:

<div data-lift="embed?what=/footer"></div>

The templating engine will also allow you to use other directives like surround if you want to insert content at a particular point in the middle of an existing HTML file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top