Coder Social home page Coder Social logo

kevintcoughlin / jekyll-include-cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benbalter/jekyll-include-cache

0.0 1.0 0.0 10 KB

A Jekyll plugin to cache the rendering of Liquid includes

License: MIT License

Ruby 98.43% Shell 1.57%

jekyll-include-cache's Introduction

Jekyll Include Cache

A Jekyll plugin to cache the rendering of Liquid includes

Build Status

What it does

If you have a computationally expensive include (such as a sidebar or navigation), Jekyll Include Cache renders the include once, and then reuses the output any time that includes is called with the same arguments, potentially speeding up your site's build significantly.

Usage

  1. Add the following to your site's Gemfile:
gem 'jekyll-include-cache'
  1. Add the following to your site's config file:
gems:
  - jekyll-include_cache
  1. Replace {% include foo.html %} in your template with {% include_cached foo.html %}

One potential gotcha

For Jekyll Include Cache to work, you cannot rely on the page context to pass variables to your include (e.g., assign foo=bar or page.title). Instead, you must explicitly pass all variables to the include as arguments, and reference them within the include as include.foo (instead of page.foo or just foo).

Good

In your template:

{% include_cached shirt.html size=medium color=red %}

In your include:

Buy our {{ include.color }} shirt in {{ include.size }}!

Bad

In your template:

{% assign color=blue %}
{% include_cached shirt.html %}

In your include:

Buy our {{ color }} shirt in {{ page.size }}!

jekyll-include-cache's People

Contributors

benbalter avatar

Watchers

James Cloos avatar

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.