How to get 11ty generate html fragment - eleventy

how can I get 11ty to create an html fragment?
I have a .md file which 11ty renders with liquid and the generated html has a head and a body. I would like to resulting .html to contain only the content without a head element and not wrapped in a body element.
Thanks

Related

Convert html to pdf using prawn in ruby on rails

I am working on a Rails project and I need to convert the HTML page to a PDF page but it's writing HTML as it is on a pdf page. PDF page is not showing like a webpage. How can I generate a proper PDF from an HTML file?
Prawn::Document.generate("test.pdf") do
filepath = ${filepath}"file.html"
data = File.read(filepath);
text data
end
prawn is not really an HTML to PDF generator - see https://github.com/prawnpdf/prawn#should-you-use-prawn
You'll need to use another tool, for example wicked_pdf - see https://github.com/mileszs/wicked_pdf#super-advanced-usage
In your case, to quote from the README, you'll need something like
# create a pdf file from a html file without converting it to string
# Path must be absolute path
pdf = WickedPdf.new.pdf_from_html_file('/your/absolute/path/here')

why Special characters apostrophe and others shows like this ’, in HTMl file

I have a markdown file in UTF-8 without BOM encoding format[md file generated tool from word document] . Converted this markdown to HTML using jekyll tool. The following special characters available(apostrophe,hypen so on) in md file content .
1.example content in MD:
dont't, **ListView** control
Converted HTMl format like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>dont’t, <strong>ListView</strong> control</p>
</body>
</html>
We can get exact result dont’t, ListView control when open the html file. I want to use the same html file loaded in to ASP.NET MVC razor view through Html.Action. syntax given below
MVC Razor view access the html file via action method:
Html.Action("GetHtmlPage", "Products", new {path = "~/Views/Products/WhatsNew/" + Model.Platform + ".html"}))
Action code:
public ActionResult GetHtmlPage(string path)
{
return new FilePathResult(path, "text/html");
}
Using the above MVC syntax , i can successfully loaded HTMl file into my View. But the output are show below like in browser and HTMl template like previous format.
dont’t, ListView control
Apostrope viewed as', ’
 string added after bold element.
How to view the special characters in browser , when loaded html file into razor view.? I have sticking as long as today.
It appears that your HTML document is advertising itself as UTF-8. However, it if is not actually in UTF-8 format, or if the Markdown file is not in UTF-8, either could be causing the characters to not actually be UTF-8 encoded characters. So check the encodings of your files.
If that doesn't resolve the problem, then you need to use HTML Entities. Or you need to use ASCII text only for punctuation.
For example, look at the apostrophe in your sample HTML, note that it is slanted at an angle (a single right quote, unicode character U+2019) as opposed to the strait apostrophe (unicode character U+0027 - which is also an ASCII character).
Note that for those characters to display reliably in HTML documents, it is best to use the HTML Entities for those characters. Therefore, the markdown document should look this this:
Don’t, **ListView** control
The HTML entity ’ tells the browser to display a single right quote, unicode character U+2019.
Note that Markdown does not convert such characters to HTML entities for you. You have to do it yourself. You could use SmartyPants to do conversions, but it converts the ASCII characters to the richer characters as HTML entities. In that case, your Markdown should look like this:
Don't, **ListView** control
Of course, you could just use the ASCII characters and not bother with SmartPants if you want.
However, be aware that if you are using MS Word, that program is configured by default to replace the ASCII character you type (using the apostrophe key on you keyboard) with the fancy character automatically. It is generally recommended that a word processor (like MS Word) not be used for editing Markdown documents for this reason. Use a plain text editor instead.
If you really must use MS Word there are a few ways to disable the auto-replace behavior. See this for more info about how word processors act with these types of characters and how to disable that behavior.
I was having this same problem with a markdown to html converter (pandoc) and I found the solution here. Just adding the following header solved my issue:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

rendering partials within filters in middleman

I'd like to display a form within a :php filter in my Middleman Haml source file. Here's what I've tried:
:php
$someVar="#{= "my/partial"}"
It doesn't work. How do I render a partial within a filter? Simply outputting the value of a Ruby variable with the Haml code (rendered to HTML) would also be acceptable.

Thymeleaf. Why each html file have sections: html, head, body?

I was wondering Why Thymeleaf always have same tags like:
<html>
<head></head>
<body></body>
</html>
In each file with template html?
That's the standard structure for an HTML file. Everything goes inside these tags.

Display html file inside iframe

How to display a HTML file from my system in iframe using rails?
I will explain my issue...
I have a view file that has an iframe which calls an action through <iframe src="controller/action?param=somevalue"></iframe> and the action renders a HTML file based on the params.
The HTML file called has reference to stylesheets and javascripts in the format <script type="text/javascript" src="../common/About.js"></script>
When viewed in browser the HTML file displays correctly with the styles and javascript but when viewed in the application the styling and scripts are not working from the external file. On viewing the source code for the external files i get "Unknown action" error.
What is that i am doing wrong in this?
(reacting to yr last comment): you need to specify css and js files in the iframed html page separately. html in an iframe is rendered completely independent from the surrounding page.
This is not a rails-related question imho.
I found the mistake I made. Its because of routes being not defined properly. When I give relative urls in the html file, the rails views assumes the full path to be some thing like src="controller/common/About.js". As there is no action defined by the name common I was getting the Unknown action error. I have redefined my routes and its working fine now.

Resources