-
Notifications
You must be signed in to change notification settings - Fork 6
File Inclusion
This was the original use case that led to the development of Denina. The original requirement was to allow editorial file inclusion so that editors could output markup from files on the file system.
This can be achieved with a single command:
File.Read -file:my-content.html
This command set will read the contents of my-content.html relative to the directory specified under the File.BaseIncludePath global variable (see Configuration). The contents of the file will be output from the filter, and since there is no subsequent filter, the raw content will be the output of the pipeline.
If the file was a text file which needed HTML line breaks added, this can be achieved with a second filter:
File.Read -file:my-content.txt
Html.LineBreaks
The Html.LineBreaks filter would operate on its input text, which is the output of the File.Read operation. It would replace newlines with <br/> tags and output the result.
If the file is a full HTML document, and you would only like to include the contents of the BODY tag:
File.Read -file:my-content.html
Html.Extract -path:body
This would read the contents of the file, parse the HTML, extract the contents of the BODY tag, and output the result.
Finally, if the content of the file was Markdown, a developer could write a simple custom filter to process this (this is using the Markdig library, but there are others):
Pipeline.FilterDelegate markdownFilter = (input, command, log) =>
{
return Markdown.ToHtml(input);
}
Pipeline.AddMethod(markdownFilter, "Markdown", "Process");Once loaded (see Writing Filters), this filter could be added to the command set and chained like this:
File.Read -file:my-content.md
Markdown.Process
This would read the text content of the file, transform the markup, and output the result.
- Next: HTTP and Web Services
Confused? See Definitions.
Still confused? Email Deane or file an issue.
Denina is a weird hobby project that Blend Interactive generally tolerates.
- Introduction
- Definitions
- Denina for Editors
- Denina for Developers
- Examples and Tutorials
- Implementations
- About
- Roadmap
Filter Command Reference
(auto-generated API documentation)