Giter Club home page Giter Club logo

Comments (10)

mathroc avatar mathroc commented on May 10, 2024

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.

yckart avatar yckart commented on May 10, 2024

@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.

johnko avatar johnko commented on May 10, 2024

@yckart @mathroc

I like the snippet idea, I may do that.

Use case:

  • large legal footer
  • text heavy content in sidebars

from pico.

yckart avatar yckart commented on May 10, 2024

@johnko I would be glad! :-)

from pico.

mathroc avatar mathroc commented on May 10, 2024

@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.

johnko avatar johnko commented on May 10, 2024

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.

mathroc avatar mathroc commented on May 10, 2024

@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.

ghuger avatar ghuger commented on May 10, 2024

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.

johnko avatar johnko commented on May 10, 2024

@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.

yckart avatar yckart commented on May 10, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.