Okay so I have my index.html file which has a file called info.html which exntends from the index.html file but it isn't quite working currently. Here's my code:
index.html
<body>
{% include "home/quote.html" %}
{% include "home/intro.html" %}
{% block content %}
{% endblock %}
{% include "home/projects.html" %}
{% include "home/goals.html" %}
</body>
info.html
{% extends "home/index.html" %}
{% block content %}
<section class="info-section">
<div class="info-section_content">
{% include "home/includes/info-content.html" %}
</div>
</section>
{% endblock %}
Essy Fix!
In views.py in the apps directory i was rendering the parent file (index.html) so I have now switch to render the child file (info.html) and it now works.
I would need some more information on your project to know for sure, but I would check to make sure that you are referencing the proper namespace here:
{% extends "home/index.html" %}
For instance if the path is something like templates/home/something/info.html or templates/something/home/info.html this could be the issue.
Related
I have a base.html template which contains basic html definitions .The other templates are defined below
// pages/dashboard.html
{% extends 'base.html' %}
{% block body %}
{% include 'components/nav.html' %}
{% include 'components/dashboard.html' %}
{% endblock %}
// components/dashboard.html
<div class="page-container">
<div class="main-page">
{% block dashboard %}
{% endblock %}
</div>
</div>
// mailer/new.html
{% extends 'pages/dashboard.html' %}
{% block dashboard %}
<h1>hello</h1>
{% endblock %}
The view renders mailer/new.html the problem is that the block containing <h1>hello</h1> is not working. Where am i going wrong with that ?
{% include %} doesn't work that way. See the note in the documentation for that tag:
Blocks are evaluated before they are included. This means that a template that includes blocks from another will contain blocks that have already been evaluated and rendered - not blocks that can be overridden by, for example, an extending template.
I have an _includes folder, and within it I have nav subfolder containing a nav.html file.
I've been trying to check if nav.html exists in nav. If it does, I want to include that nav.html file. If it doesnt exist, there will be a default nav for my template.
Here's the code I have right now:
{% for static_file in site.static_files %}
{% if static_file.path == '/nav.html' %}
{% include nav.html %}
{% endif %}
{% endfor %}
Hope you guys can help me out.
Many thanks in advance
I am not able to find the solution using existing liquid tags so I solved this by using a plugin with a custom liquid tag.
{% capture fileExists %}{% file_exists _includes/nav/custom/nav.html %}{% endcapture %}
{% if fileExists=="true" %}
{% include /nav/custom/nav.html %}
{% else %}
{% include /nav/default/nav.html %}
{% endif %}
See GitHub Repo
I am using Github Pages' Jekyll integration. I added the Disqus configuration today but Disqus does not appear on my posts. I have added the Disqus script to a file _includes/disqus.html and added {% include disqus.html %} to _layouts/default.html.
You may view this work at my https://github.com/shaneoston72/shaneoston72.github.io
Thank you for any help you can offer.
Ok, we'll need to do a few things here:
At the end of your file _layouts/default.html what I see is:
</div>
{% include disqus.html %}
{% include footer.html %}
</body>
Replace this part for:
</div>
{% include footer.html %}
{% if page.comments %}
{% include disqus.html %}
{% endif %}
</body>
Then, on your file _includes/disqus.html, delete the first and the last line:
{% if post.comments %}
.....
{% endif %}
This should do the job. Let me know how it goes, ok?
Hope to have helped!
I downloaded the whole package of Bootstrap(the middle one) and was looking into its hierarchy. I found out that this source code contains the site http://getbootstrap.com/.
For example, it has the html file of getting-started page looks like this:
---
layout: default
title: Getting started
slug: getting-started
lead: "An overview of Bootstrap, how to download and use, basic templates and examples, and more."
---
{% include getting-started/download.html %}
{% include getting-started/whats-included.html %}
{% include getting-started/grunt.html %}
{% include getting-started/template.html %}
{% include getting-started/examples.html %}
{% include getting-started/tools.html %}
{% include getting-started/community.html %}
{% include getting-started/disabling-responsiveness.html %}
<!-- Cross link to new migration page -->
<div class="bs-callout bs-callout-info" id="migration">
<h4>Migrating from v2.x to v3.x</h4>
<p>Looking to migrate from an older version of Bootstrap to v3.x? Check out our migration guide.</p>
</div>
{% include getting-started/browser-device-support.html %}
{% include getting-started/third-party-support.html %}
{% include getting-started/accessibility.html %}
{% include getting-started/license.html %}
{% include getting-started/translations.html %}
I know it can be rendered into static site by some kind of template render engine. But how to do it?
I am using the Django template system in my app, and in the child template I reference the {% extends "base.html" %} accordingly, though when redenring the template, it only comes up with the html tags and no css styling-thus not picking up the base.html template altogether.
Please advise on what I am doing wrong?. Could it be an issue with it not finding the location of my base.html template?
This is the child template code:
{% extends "base.html" %}
{% block content %}
{% for field in form %}
{{ form }}
{% endfor %}
{% endblock %}
This is the base.html template code (relevant parts):
<div id="content">
<h2>
Page heading - This is where the functionality goes...
</h2>
<FIELDSET><INPUT class=Test value="Test" type=submit></FIELDSET>
{% block primary %}{% endblock %}
</div>
Please let me know if you need any firther information to solve this issue.
-I will add the views.py this evening (London time)--
This all all sorted, many thanks for the help
Thanks
Like goliney mentioned...
You need to have a part in your base.html file that has
{% block content %}
{% endblock %}
Then you can override that in your other template that extends the base.html template.
Currently in your child template you could do a
{% block primary %}
whatever you want here and this would show up where you marked on the base.html template
{% endblock %}
Also not sure if you are just putting together a quick example or not. You will need to create the
<form action="" method="post">{% csrf_token %}
for loop here
</form>