I'm using django-inlinecss to style emails.
Here's a snippet of my email template:
{% extends "base/email.html" %}
{% block content %}
{% load inlinecss %}
{% inlinecss "base/css/email.css" %}
<p class="c-c-test">test</p>
{% endinlinecss %}
{% endblock %}
When rendering the template, an error occurs saying:
No such file or directory: '/usr/src/project/static/base/css/email.css'
Although, trying to use the same css file path (i.e. "base/css/email.css") with static template tag works fine.
What am I doing wrong here?
EDIT:
I'm using docker, django-inlinecss seems to load the css file from local storage (i.e. from docker image) where there's no such file. The actual file is located on my machine. Is there a workaround to solve this issue? something like how static template tag work?
Related
I am trying to extend a navbar so it appears in several pages. When I insert {% extend %} {% block content %} {% endblock %}, it only appears as text - the code dosen't work.
Here is my Navbar that I want to extend:
This is how it appears in the browser:
This is the html file I want to include my navbar in:
How it appears:
I want to inherit my navbar, but only the code text appears in the browser.
{% extend %} and so on have no special meaning in HTML.
The syntax is clearly from some template engine. Maybe Nunjucks.
You'll need to pass your source code through the template engine and use the HTML generated from it.
I created a file named base.html in the templates folder and written the code as follows:
{% block page_content %}{% endblock %}
Now, in another file named Hello_World.html I wrote the code as
{% extends "base.html" %}
{% block page_content %}
<h1>Hello, World!</h1>
{% endblock %}
can anyone please explain the working of this code clearly as I didn't come across the commands block and endblock in css.To the one who answers Thank you very much in Advance!
This is Django.
block is used for overriding specific parts of a template.
You could have a block named content and this is supposed to be overridden by children that inherit from this template.
From the examples at The Django Docs
I am currently a beginner in html and I have seen this problem many times and I do not know how to solve it. I copied a source code from a video in an attempt to make a social media. The following code is in the file home.html:
{% extends 'base.html' %}
{% block title %}
home
{% endblock title %}
{% block content %}
{{hello}}
<br>
{{user}}
{% endblock content %}
{% block scripts %}
<script>
$(document).ready(function(){
console.log('working')
})
</script>
{% endblock scripts %}
However, in the video the html page seems correct and all buttons and functions are working. On the other side my html page is like this:
...
The guide you have seen concerns Flask, a framework for applications written in Python. The code will not work because there is no preprocessor that can process it. In this case the browser will show you plain text without formatting.
How can I use the include_relative tag correctly?
I have my folder layout and files like so.
my-account.html
_includes
page-content
my-account
my-account.html
header.html
nav.html
In my-account.html I include the following file.
{% include page-content/my-account/my-account.html %}
All good.
However, inside the my-account.html from the includes folder, I am also calling header.html and nav.html
{% include page-content/my-account/header.html %}
{% include page-content/my-account/nav.html %}
Is there a way to use include_relative like this from the my-account.html since its in the same folder?
{% include_relative header.html %}
{% include_relative nav.html %}
Currently I get the error:
'./header.html' not found, so obviously the include_relative is not working.
Thanks!
Try this to the file my-account.html:
{% include /page-content/my-account/header.html %}
{% include /page-content/my-account/nav.html %}
I've tested here with a similar structure and worked, then you should be ok. ;)
I am developing an application using Symfony2 and twig for templates. I am using a 3 level structure for templates. Base.html.twig, layout.html.twig and childtemplate.html.twig.
The problem is I am trying to include one example.html (common html file) in the next child template by using include but it doesnt work properly. Where can the problem be?
{# src/Anotatzailea/AnotatzaileaBundle/Resources/views/Page/testuaanotatu.html.twig #}
{% extends 'AnotatzaileaAnotatzaileaBundle::layout.html.twig' %}
{% block title %}Testua anotatu{% endblock%}
{% block body %}
{% include "var/www/Symfony/web/example.html" %}
{% endblock %}
Depends on where it's located. Let's say it's in Anotatzailea/AnotatzaileaBundle/Resources/views/example.html.twig; then you would include it like this:
{% include 'AnotatzaileaAnotatzaileaBundle::example.html.twig' %}