Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to render partials in static html5 pages

Currently writing a static website for a collage project. I would like to render a sidebar as a partial.

I know how to do this with Ruby on Rails but am unaware of how to set it up on a static page as we are only aloud the use of html5, css and javascript. Rendering a partial will improve working speed and keep clean code.

If this is how it is rendered in the html with Ruby on Rails

<%= render "shared/menu" %>

What would my line look like without the rails system.

Any help is very much appreciated.

like image 961
Joe Lloyd Avatar asked Nov 28 '14 16:11

Joe Lloyd


People also ask

What is render partial in rails?

Rails Guides describes partials this way: Partial templates - usually just called "partials" - are another device for breaking the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.

What is rendering in HTML?

The Render Function The purpose of the function is to display the specified HTML code inside the specified HTML element.

How do I render a page?

Rendering a webpage is the process of turning HTML, CSS, and JavaScript code into an interactive page that website visitors expect to see when clicking on a link. Every website page is designed with the end user in mind.


2 Answers

I believe if you look at something like HTML Imports, this could solve your question. It caters for great flexibility and re-usability. You declare your partial import, simply by adding:

<link rel="import" href="/shared/menu.html">

to your html page.

like image 94
Donald N. Mafa Avatar answered Oct 17 '22 12:10

Donald N. Mafa


I would highly suggest using the Middleman Static site generator. It is perfect if you are just wanting to build a static site and it is written in Ruby. Their homepage is down, but I've linked their github page that has instructions of how to set it up.

Once setup, the code to render partials will be <%= partial shared/menu %>

like image 1
celly Avatar answered Oct 17 '22 11:10

celly