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.
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.
The Render Function The purpose of the function is to display the specified HTML code inside the specified HTML element.
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.
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.
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 %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With