Comments (10)
When you suggesting {{ content.page }}
you're thinking to use it in the template? why would you do that?
Anyway you can't do that from the template and neither from your markdown-ed content
from pico.
@mathroc I've some large pages and want to keep them clean. So I thought why not creating a sub-folder in each page and call it snippets
for example, so i can then get them via shortcode. Or even better combined with your draft
-approach as snippet
extension ;-)
from pico.
I like the snippet idea, I may do that.
Use case:
- large legal footer
- text heavy content in sidebars
from pico.
@johnko I would be glad! :-)
from pico.
@yckart yeah I get the idea when it's in markdown. In the template I think there is something similar that' already possible : http://twig.sensiolabs.org/doc/templates.html#including-other-templates
but that way you can't include markdown content (if you do it won't be transformed into html). That should be enough for the content that is present in every page.
@yckart @johnko anyway the the .snippet thing could be useful for complex pages or for content that you might want to reuse. And I think using .snippet would be better than be able to include any content. That's because you might not wish the snippet content to be discoverable alone.
from pico.
So let's have some sort of plan before I start coding.
Would it make sense to add another metaheader (like when you did Theme
) but this time for Snippet: keyname content/path/file.snip
?
Then the flow somewhere after calling read_file_meta
parsing would be to grab any file and allow it to pass through to twig (theming) as {{ snippet.keyname }}
??
from pico.
@johnko I'm not sure, I was thinking about using snippet into the markdown content, something like:
# my title
[include:chapter1]
[include:chapter2]
[include:chapter3]
which would replace [include:chapter1] by chapter1.snippet file content before transforming markodwn into html.
if you want to use snippet in the template, it depends on what you're trying to achieve, I can think of 2 features:
first, your template have emplacement for potential additional content (eg: left_column, right_column, header, etc.) and this content is not always the same (if it's always the same you can just use http://twig.sensiolabs.org/doc/templates.html#including-other-templates ). In that case, yes you could have an additional header to assign an additional content, eg :
/**
* snippets: left_column=column2,header=main_header
**/
alternative syntax (require more change in the function parsing header metadata):
/**
* snippets.left_column : column2
* snippet.header : main_header
**/
then it's about as you said, the only difference I introduced is that you can have multiple snippets
the second feature would be to write part of the template in markdown, that would be solved as a Twig tag extension : http://twig.sensiolabs.org/doc/advanced.html#tags with a snippet tag you could do, in the your template:
<html>
<head>
<title>My title</title>
</head>
<body>
<div id="left_column">{{ snippet left_column }}</div>
<div id="right_column">{{ snippet right_column }}</div>
<div id="main">....</div>
</body>
</html>
not sure what you and @yckart are interested in
from pico.
I added a snippet tag so that I could have a global sidebar that is easy to update. I tried to base the solution around the excellent suggestions in this thread - it works like the second example that @mathroc posted above.
I would really appreciate any feedback!
from pico.
@ghuger Looks pretty good to me, I might do a pull request into my fork after I get around to testing this!
Thanks a bunch!
from pico.
@ghuger Yeah, nice work! I'll took myself deeper in it when I'm not so busy. But looks pretty good so far.
from pico.
Related Issues (20)
- Suboptimal process of process pages id HOT 4
- RSS Support? HOT 5
- Directory HOT 5
- Wrong config keys in `discoverPageSiblings` HOT 1
- New v3 alpha please HOT 2
- Dead? HOT 3
- Twig function to find and replace Obsidian image link syntax HOT 2
- old twig-version: v2.12.5; eol in 2023; Security issue? How to update? HOT 6
- Pico 3.0: Param 'date_format' from config.yml.template leads to PHP Fatal Error HOT 2
- Reverse case sensitive declaration of meta attributes is confusing HOT 5
- Twig 2.x and YAML 3.x not supported HOT 3
- Visit counter HOT 24
- Reading Time HOT 2
- Best way to add script inside <head> HOT 4
- picocms.org is down right now HOT 3
- Nice Date filter HOT 3
- pre-bundled release: Getting "HTTP ERROR 500" HOT 7
- Support for Twig extensions? HOT 3
- cookbook issue HOT 8
- [draft ] Autoload extra stuff HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pico.