I tried to include a tpl file using smarty include file like this,
{include file='file_name.tpl'}
its not working for me. Is it needed to include path name.
Try to set path to templates before. So call setTemplateDir before rendering of your template.
More here: https://www.smarty.net/docs/en/api.set.template.dir.tpl
Also as I can see Smarty allows to specify full path to template file inside of include directive. So even this is possible:
{include file='file:/usr/local/share/templates/navigation.tpl'}
But personally I would not recommend you to use this approach and stick to setTemplateDir and consistent place for templates in your app.
Little more information on that topic: https://www.smarty.net/docs/en/resources.tpl
Related
I have a .html which needs data inserted from svelte using ${} syntax. I haven't found any way to include that html without resorting to inserting as a string into the svelte component.
There is not much Svelte can do here, for Svelte to do it's thing it requires a compile step.
If it's possible to rename the .html file to a .svelve file and compile it like the other components, that would be preferable.
But when the html comes from an api that's not possible.
An option is to use Handlebars or another template engine to insert data from Svelte into the html. (but that resorts to inserting it as a string, see REPL)
A last option I can think of is to place a <div bind:this={el} /> and use DOM api's to create and manage the html (not recommended)
Does HTML support splitting source over multiple files? I'm looking for some equivalent of C++'s #include; or maybe something like C#'s partial; an element that could take source path and inject the file contents at that place.
Apologies if this has been asked before. Google and SO searches didn't return much. I'm not a web guy, but the only solution I found was using an iframe, which many people do not like for various reasons.
It is just that my html source is becoming huge and I want to manage it by splitting into multiple files.
You can't, at least not in flat-HTML. What you can do is using Javascript to load and place the snippets. iframes are also non-ideal because contrary to what happens with directives like #include and partial, those snippets will never be compiled in one single page.
However, I think it's important here to understand how your pages will be served. Is this a static website? Because in this case I would write a simple script in your language of choice to compile the page. Let's say that you have a base like this:
<html>
<head>
<!-- ... -->
</head>
<body>
{{ parts/navigation.html }}
<!-- ... -->
</body>
</html>
You could write a script that runs through this file line by line and loads the content into a variable named, for example, compiled_html. When it finds {{ file }} it opens file, reads its content and append it to compiled_html. When it gets to the end, it writes the content of the variable into a HTML file. How you would implement it depends on the languages you know. I'm sure that it's pretty straightforward to do it in C#.
This way you'll be able to split the source of your HTML pages into multiple files (and reuse some parts if you need them), but you'll still end up with fully functional single files.
It is easily possible, if you are running PHP:
The PHP Language has the "include" command built in.
Therefore you can have your "index.php" (note you have to change the suffix, for the PHP parser to kick-in) and simply use following syntax.
<html>
<head>
[...] (header content you want to set or use)
</head>
<body>
<?php
include "relative/path/to/your/firstfile.html";
include "relative/path/to/your/secondfile.html";
include "relative/path/to/your/evenwithothersuffix/thirdfile.php";
include "relative/path/to/your/fourth/file/in/another/folder.html";
?>
[...] (other source code you whish to use in the HTML body part)
</body>
</html>
Basically making you main index.php file a container-file and the included html files the components, which you like to maintain seperately.
For further reading I recommend the PHP Manual and the W3Schools Include Page.
not possible with static html.
in general, this problem (lazy-fetching of content) is solved with a template processor.
two options:
template processor runs on the server side
any language
static website generators, server side rendering
template processor runs on the client side
javascript
web frameworks
This seems like it should be straightforward but I've been prowling the documentation and web and haven't found the answer.
I want to output HTML doc from Sphinx. Ideally I'd like to have three levels of "note" type highlighted text boxes. ReST defines several "admonitions": (http://docutils.sourceforge.net/docs/ref/rst/directives.html#admonitions) but most of the Sphinx HTML themes include special formatting only for Note and Warning. (I am using one of the preinstalled themes, Classic.)
I have two questions:
1) How can I customize the color behind Warning in my documents?
2) How can I add a formatting style for Caution?
I see that these all end up with tags like <div class="admonition warning"> ... in the HTML output. But I can't find where the formatting for that class is defined. Is it in a stylesheet? Is it in a layout.html file or some other file?
Is there anything that explains how the various files in themes actually interact with each other? I haven't found a good primer. (I am no expert on css-based HTML either, so maybe that's part of the problem.)
Okay, I figured out more and have a working workaround. (I'm still not sure how I'm supposed to handle this.)
Looks like my HTML code is reading directly from a few cascading stylesheets stored along with the output in a directory called _static. There's classic.css, which inherits from basic.css.
I don't understand how these relate to the files named like basic.css_t that live in the Python Sphinx install.
To change things, should I (A) try altering the _t files? or (B) create an altered local copy of classic.css that lives in my source directory?
If I go with B, more questions.
Will it be overwritten by the values in the css_t template at build time? (I guess this is easy enough to test)
Is it good practice to use the same filename for a modified version of that stylesheet?
Here's a workaround that avoids those questions and seems to be doing what I want - from this: https://github.com/snide/sphinx_rtd_theme/issues/117
I created an override stylesheet that includes just the formatting I want to change.
I stored it in the _static of my source directory.
I defined it in my conf.py as follows:
html_context = {
'css_files': [
'_static/theme_overrides.css',
],
}
Now, that github discussion said that this wasn't a solution for all kinds of themes (including the RTD theme mentioned in the question) but I think I'm safe for now.
What more should I know?
When using jade, AngularJs and angular-translate I prefer to use the translate directive as an empty attribute.
But for some reason, when using empty attributes in Jade, instead of getting something like <tag translate OR <tag translate='', I'm getting <tag translate='translate'
How can I add an attribute without a value?
The answer is to use the {doctype: "html"} when using the Pug (before was Jade) template engine.
This option has been documented recently, but it does not states what is it for.
Bear in mind that since I'm just processing all the jade files using gulp, I don't care that much about partials and such things...
Caveats: as stated by #lmacsen at github:
This fail if you need to use that code into a partial html file.
I've come up with this answer after reading several other github issues in the project page.
https://github.com/pugjs/pug/issues/201#issuecomment-1530205
https://github.com/pugjs/pug/issues/1180
I'm Using .foo(bar="") and it produces <div bar class="foo"></div>.
Using .foo(bar) you will get <div bar="bar" class="foo"></div>.
I'm Using most recent versions of Pug (formerly known as Jade) and I'm also using Partial jade files.
I have a portal that is under a virtual host in Apache. All lot of its .css and .js is generated dynamically by the underlying tomcat web application. What I want to do is inject some of my own .css and .js into the mix before it is served. I think I need something like mod_rewrite but for html.
I know I could try to piggyback onto some resource reference that is used on every page and use mod_rewrite that way, but that is hard to do and I need my css to be applied last.
Tell me there are some magic beans for this. I just need to inject a couple scripts and styles right at </head>.
I haven't used it before, but it looks like mod_ext_filter could do this
By looking at the example, you could try the following Perl script
#!/usr/local/bin/perl -w
use strict;
my $extraCode = "<script src=\"http:/...\"></script>";
while (<STDIN>) {
s/<\/head>/$extraCode<\/head>/i;
print;
}
After I posted this, I noticed someone recommended https://serverfault.com/questions/46449/how-to-inject-html-code-into-every-delivered-html-page. mod_proxy_html and mod_sed looks good