{"id":13463256,"url":"https://github.com/zendesk/curly","last_synced_at":"2025-05-14T09:06:34.731Z","repository":{"id":6491779,"uuid":"7732169","full_name":"zendesk/curly","owner":"zendesk","description":"The Curly template language allows separating your logic from the structure of your HTML templates.","archived":false,"fork":false,"pushed_at":"2024-12-30T12:38:04.000Z","size":639,"stargazers_count":591,"open_issues_count":15,"forks_count":20,"subscribers_count":425,"default_branch":"main","last_synced_at":"2025-04-11T22:19:48.294Z","etag":null,"topics":["curly-template","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zendesk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-01-21T12:50:06.000Z","updated_at":"2025-01-25T02:47:46.000Z","dependencies_parsed_at":"2024-01-15T17:12:27.559Z","dependency_job_id":"7ed4082f-2941-468f-8669-d89888c96f8f","html_url":"https://github.com/zendesk/curly","commit_stats":{"total_commits":387,"total_committers":17,"mean_commits":"22.764705882352942","dds":0.2609819121447028,"last_synced_commit":"0d7ff35f38434cb4612f5279e6e3667aeed9608f"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fcurly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fcurly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fcurly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fcurly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/curly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253692277,"owners_count":21948313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curly-template","ruby"],"created_at":"2024-07-31T13:00:49.086Z","updated_at":"2025-05-14T09:06:34.712Z","avatar_url":"https://github.com/zendesk.png","language":"Ruby","funding_links":[],"categories":["HTML \u0026 Markup","Template Engine","Ruby"],"sub_categories":["Template Engines"],"readme":"Curly\n=======\n\nCurly is a template language that completely separates structure and logic.\nInstead of interspersing your HTML with snippets of Ruby, all logic is moved\nto a presenter class.\n\n\n### Table of Contents\n\n1. [Installing](#installing)\n2. [How to use Curly](#how-to-use-curly)\n    1. [Identifiers](#identifiers)\n    2. [Attributes](#attributes)\n    3. [Conditional blocks](#conditional-blocks)\n    4. [Collection blocks](#collection-blocks)\n    5. [Context blocks](#context-blocks)\n    6. [Setting up state](#setting-up-state)\n    7. [Escaping Curly syntax](#escaping-curly-syntax)\n    8. [Comments](#comments)\n3. [Presenters](#presenters)\n    1. [Layouts and content blocks](#layouts-and-content-blocks)\n    2. [Rails helper methods](#rails-helper-methods)\n    3. [Testing](#testing)\n    4. [Examples](#examples)\n4. [Caching](#caching)\n\n\nInstalling\n----------\n\nInstalling Curly is as simple as running `gem install curly-templates`. If you're\nusing Bundler to manage your dependencies, add this to your Gemfile\n\n```ruby\ngem 'curly-templates'\n```\n\nCurly can also install an application layout file, replacing the .erb file commonly\ncreated by Rails.  If you wish to use this, run the `curly:install` generator.\n\n```sh\n$ rails generate curly:install\n```\n\n\nHow to use Curly\n----------------\n\nIn order to use Curly for a view or partial, use the suffix `.curly` instead of\n`.erb`, e.g. `app/views/posts/_comment.html.curly`. Curly will look for a\ncorresponding presenter class named `Posts::CommentPresenter`. By convention,\nthese are placed in `app/presenters/`, so in this case the presenter would\nreside in `app/presenters/posts/comment_presenter.rb`. Note that presenters\nfor partials are not prepended with an underscore.\n\nAdd some HTML to the partial template along with some Curly components:\n\n```html\n\u003c!-- app/views/posts/_comment.html.curly --\u003e\n\u003cdiv class=\"comment\"\u003e\n  \u003cp\u003e\n    {{author_link}} posted {{time_ago}} ago.\n  \u003c/p\u003e\n\n  {{body}}\n\n  {{#author?}}\n    \u003cp\u003e{{deletion_link}}\u003c/p\u003e\n  {{/author?}}\n\u003c/div\u003e\n```\n\nThe presenter will be responsible for providing the data for the components. Add\nthe necessary Ruby code to the presenter:\n\n```ruby\n# app/presenters/posts/comment_presenter.rb\nclass Posts::CommentPresenter \u003c Curly::Presenter\n  presents :comment\n\n  def body\n    SafeMarkdown.render(@comment.body)\n  end\n\n  def author_link\n    link_to @comment.author.name, @comment.author, rel: \"author\"\n  end\n\n  def deletion_link\n    link_to \"Delete\", @comment, method: :delete\n  end\n\n  def time_ago\n    time_ago_in_words(@comment.created_at)\n  end\n\n  def author?\n    @comment.author == current_user\n  end\nend\n```\n\nThe partial can now be rendered like any other, e.g. by calling\n\n```ruby\nrender 'comment', comment: comment\nrender comment\nrender collection: post.comments\n```\n\nCurly _components_ are surrounded by curly brackets, e.g. `{{hello}}`. They always map to a\npublic method on the presenter class, in this case `#hello`. Methods ending in a question mark\ncan be used for [conditional blocks](#conditional-blocks), e.g. `{{#admin?}} ... {{/admin?}}`.\n\n### Identifiers\n\nCurly components can specify an _identifier_ using the so-called dot notation: `{{x.y.z}}`.\nThis can be very useful if the data you're accessing is hierarchical in nature. One common\nexample is I18n:\n\n```html\n\u003ch1\u003e{{i18n.homepage.header}}\u003c/h1\u003e\n```\n\n```ruby\n# In the presenter, the identifier is passed as an argument to the method. The\n# argument will always be a String.\ndef i18n(key)\n  translate(key)\nend\n```\n\nThe identifier is separated from the component name with a dot. If the presenter method\nhas a default value for the argument, the identifier is optional – otherwise it's mandatory.\n\n\n### Attributes\n\nIn addition to [an identifier](#identifiers), Curly components can be annotated\nwith *attributes*. These are key-value pairs that affect how a component is rendered.\n\nThe syntax is reminiscent of HTML:\n\n```html\n\u003cdiv\u003e{{sidebar rows=3 width=200px title=\"I'm the sidebar!\"}}\u003c/div\u003e\n```\n\nThe presenter method that implements the component must have a matching keyword argument:\n\n```ruby\ndef sidebar(rows: \"1\", width: \"100px\", title:); end\n```\n\nAll argument values will be strings. A compilation error will be raised if\n\n- an attribute is used in a component without a matching keyword argument being present\n  in the method definition; or\n- a required keyword argument in the method definition is not set as an attribute in the\n  component.\n\nYou can define default values using Ruby's own syntax. Additionally, if the presenter\nmethod accepts arbitrary keyword arguments using the `**doublesplat` syntax then all\nattributes will be valid for the component, e.g.\n\n```ruby\ndef greetings(**names)\n  names.map {|name, greeting| \"#{name}: #{greeting}!\" }.join(\"\\n\")\nend\n```\n\n```html\n{{greetings alice=hello bob=hi}}\n\u003c!-- The above would be rendered as: --\u003e\nalice: hello!\nbob: hi!\n```\n\nNote that since keyword arguments in Ruby are represented as Symbol objects, which are\nnot garbage collected in Ruby versions less than 2.2, accepting arbitrary attributes\nrepresents a security vulnerability if your application allows untrusted Curly templates\nto be rendered. Only use this feature with trusted templates if you're not on Ruby 2.2\nyet.\n\n\n### Conditional blocks\n\nIf there is some content you only want rendered under specific circumstances, you can\nuse _conditional blocks_. The `{{#admin?}}...{{/admin?}}` syntax will only render the\ncontent of the block if the `admin?` method on the presenter returns true, while the\n`{{^admin?}}...{{/admin?}}` syntax will only render the content if it returns false.\n\nBoth forms can have an identifier: `{{#locale.en?}}...{{/locale.en?}}` will only\nrender the block if the `locale?` method on the presenter returns true given the\nargument `\"en\"`. Here's how to implement that method in the presenter:\n\n```ruby\nclass SomePresenter \u003c Curly::Presenter\n  # Allows rendering content only if the locale matches a specified identifier.\n  def locale?(identifier)\n    current_locale == identifier\n  end\nend\n```\n\nFurthermore, attributes can be set on the block. These only need to be specified when\nopening the block, not when closing it:\n\n```html\n{{#square? width=3 height=3}}\n  \u003cp\u003eIt's square!\u003c/p\u003e\n{{/square?}}\n```\n\nAttributes work the same way as they do for normal components.\n\n\n### Collection blocks\n\nSometimes you want to render one or more items within the current template, and splitting\nout a separate template and rendering that in the presenter is too much overhead. You can\ninstead define the template that should be used to render the items inline in the current\ntemplate using the _collection block syntax_.\n\nCollection blocks are opened using an asterisk:\n\n```html\n{{*comments}}\n  \u003cli\u003e{{body}} ({{author_name}})\u003c/li\u003e\n{{/comments}}\n```\n\nThe presenter will need to expose the method `#comments`, which should return a collection\nof objects:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n\n  def comments\n    @post.comments\n  end\nend\n```\n\nThe template within the collection block will be used to render each item, and it will\nbe backed by a presenter named after the component – in this case, `comments`. The name\nwill be singularized and Curly will try to find the presenter class in the following\norder:\n\n* `Posts::ShowPresenter::CommentPresenter`\n* `Posts::CommentPresenter`\n* `CommentPresenter`\n\nThis allows you some flexibility with regards to how you want to organize these nested\ntemplates and presenters.\n\nNote that the nested template will *only* have access to the methods on the nested\npresenter, but all variables passed to the \"parent\" presenter will be forwarded to\nthe nested presenter. In addition, the current item in the collection will be\npassed, as well as that item's index in the collection:\n\n```ruby\nclass Posts::CommentPresenter \u003c Curly::Presenter\n  presents :post, :comment, :comment_counter\n\n  def number\n    # `comment_counter` is automatically set to the item's index in the collection,\n    # starting with 1.\n    @comment_counter\n  end\n\n  def body\n    @comment.body\n  end\n\n  def author_name\n    @comment.author.name\n  end\nend\n```\n\nCollection blocks are an alternative to splitting out a separate template and rendering\nthat from the presenter – which solution is best depends on your use case.\n\n\n### Context blocks\n\nWhile collection blocks allow you to define the template that should be used to render\nitems in a collection right within the parent template, **context blocks** allow you\nto define the template for an arbitrary context. This is very powerful, and can be used\nto define widget-style components and helpers, and provide an easy way to work with\nstructured data. Let's say you have a comment form on your page, and you'd rather keep\nthe template inline. A simple template could look like:\n\n```html\n\u003c!-- post.html.curly --\u003e\n\u003ch1\u003e{{title}}\u003c/h1\u003e\n{{body}}\n\n{{@comment_form}}\n  \u003cb\u003eName: \u003c/b\u003e {{name_field}}\u003cbr\u003e\n  \u003cb\u003eE-mail: \u003c/b\u003e {{email_field}}\u003cbr\u003e\n  {{comment_field}}\n\n  {{submit_button}}\n{{/comment_form}}\n```\n\nNote that an `@` character is used to denote a context block. Like with\n[collection blocks](#collection-blocks), a separate presenter class is used within the\nblock, and a simple convention is used to find it. The name of the context component\n(in this case, `comment_form`) will be camel cased, and the current presenter's namespace\nwill be searched:\n\n```ruby\nclass PostPresenter \u003c Curly::Presenter\n  presents :post\n  def title; @post.title; end\n  def body; markdown(@post.body); end\n\n  # A context block method *must* take a block argument. The return value\n  # of the method will be used when rendering. Calling the block argument will\n  # render the nested template. If you pass a value when calling the block\n  # argument it will be passed to the presenter.\n  def comment_form(\u0026block)\n    form_for(Comment.new, \u0026block)\n  end\n\n  # The presenter name is automatically deduced.\n  class CommentFormPresenter \u003c Curly::Presenter\n    # The value passed to the block argument will be passed in a parameter named\n    # after the component.\n    presents :comment_form\n\n    # Any parameters passed to the parent presenter will be forwarded to this\n    # presenter as well.\n    presents :post\n\n    def name_field\n      @comment_form.text_field :name\n    end\n\n    # ...\n  end\nend\n```\n\nContext blocks were designed to work well with Rails' helper methods such as `form_for`\nand `content_tag`, but you can also work directly with the block. For instance, if you\nwant to directly control the value that is passed to the nested presenter, you can call\nthe `call` method on the block yourself:\n\n```ruby\ndef author(\u0026block)\n  content_tag :div, class: \"author\" do\n    # The return value of `call` will be the result of rendering the nested template\n    # with the argument. You can post-process the string if you want.\n    block.call(@post.author)\n  end\nend\n```\n\n#### Context shorthand syntax\n\nIf you find yourself opening a context block just in order to use a single component,\ne.g. `{{@author}}{{name}}{{/author}}`, you can use the _shorthand syntax_ instead:\n`{{author:name}}`. This works for all component types, e.g.\n\n```html\n{{#author:admin?}}\n  \u003cp\u003eThe author is an admin!\u003c/p\u003e\n{{/author:admin?}}\n```\n\nThe syntax works for nested contexts as well, e.g. `{{comment:author:name}}`. Any\nidentifier and attributes are passed to the target component, which in this example\nwould be `{{name}}`.\n\n\n### Setting up state\n\nAlthough most code in Curly presenters should be free of side effects, sometimes side\neffects are required. One common example is defining content for a `content_for` block.\n\nIf a Curly presenter class defines a `setup!` method, it will be called before the view\nis rendered:\n\n```ruby\nclass PostPresenter \u003c Curly::Presenter\n  presents :post\n\n  def setup!\n    content_for :title, post.title\n\n    content_for :sidebar do\n      render 'post_sidebar', post: post\n    end\n  end\nend\n```\n\n### Escaping Curly syntax\n\nIn order to have `{{` appear verbatim in the rendered HTML, use the triple Curly escape syntax:\n\n```\nThis is {{{escaped}}.\n```\n\nYou don't need to escape the closing `}}`.\n\n\n### Comments\n\nIf you want to add comments to your Curly templates that are not visible in the rendered HTML,\nuse the following syntax:\n\n```html\n{{! This is some interesting stuff }}\n```\n\n\nPresenters\n----------\n\nPresenters are classes that inherit from `Curly::Presenter` – they're usually placed in\n`app/presenters/`, but you can put them anywhere you'd like. The name of the presenter\nclasses match the virtual path of the view they're part of, so if your controller is\nrendering `posts/show`, the `Posts::ShowPresenter` class will be used. Note that Curly\nis only used to render a view if a template can be found – in this case, at\n`app/views/posts/show.html.curly`.\n\nPresenters can declare a list of accepted variables using the `presents` method:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\nend\n```\n\nA variable can have a default value:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n  presents :comment, default: nil\nend\n```\n\nAny public method defined on the presenter is made available to the template as\na component:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n\n  def title\n    @post.title\n  end\n\n  def author_link\n    # You can call any Rails helper from within a presenter instance:\n    link_to author.name, profile_path(author), rel: \"author\"\n  end\n\n  private\n\n  # Private methods are not available to the template, so they're safe to\n  # use.\n  def author\n    @post.author\n  end\nend\n```\n\nPresenter methods can even take an argument. Say your Curly template has the content\n`{{t.welcome_message}}`, where `welcome_message` is an I18n key. The following presenter\nmethod would make the lookup work:\n\n```ruby\ndef t(key)\n  translate(key)\nend\n```\n\nThat way, simple ``functions'' can be added to the Curly language. Make sure these do not\nhave any side effects, though, as an important part of Curly is the idempotence of the\ntemplates.\n\n\n### Layouts and content blocks\n\nBoth layouts and content blocks (see [`content_for`](http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for))\nuse `yield` to signal that content can be inserted. Curly works just like ERB, so calling\n`yield` with no arguments will make the view usable as a layout, while passing a Symbol\nwill make it try to read a content block with the given name:\n\n```ruby\n# Given you have the following Curly template in\n# app/views/layouts/application.html.curly\n#\n#   \u003chtml\u003e\n#     \u003chead\u003e\n#       \u003ctitle\u003e{{title}}\u003c/title\u003e\n#     \u003c/head\u003e\n#     \u003cbody\u003e\n#       \u003cdiv id=\"sidebar\"\u003e{{sidebar}}\u003c/div\u003e\n#       {{body}}\n#     \u003c/body\u003e\n#   \u003c/html\u003e\n#\nclass ApplicationLayout \u003c Curly::Presenter\n  def title\n    \"You can use methods just like in any other presenter!\"\n  end\n\n  def sidebar\n    # A view can call `content_for(:sidebar) { \"some HTML here\" }`\n    yield :sidebar\n  end\n\n  def body\n    # The view will be rendered and inserted here:\n    yield\n  end\nend\n```\n\n\n### Rails helper methods\n\nIn order to make a Rails helper method available as a component in your template,\nuse the `exposes_helper` method:\n\n```ruby\nclass Layouts::ApplicationPresenter \u003c Curly::Presenter\n  # The components {{sign_in_path}} and {{root_path}} are made available.\n  exposes_helper :sign_in_path, :root_path\nend\n```\n\n\n### Testing\n\nPresenters can be tested directly, but sometimes it makes sense to integrate with\nRails on some levels. Currently, only RSpec is directly supported, but you can\neasily instantiate a presenter:\n\n```ruby\nSomePresenter.new(context, assigns)\n```\n\n`context` is a view context, i.e. an object that responds to `render`, has all\nthe helper methods you expect, etc. You can pass in a test double and see what\nyou need to stub out. `assigns` is the hash containing the controller and local\nassigns. You need to pass in a key for each argument the presenter expects.\n\n#### Testing with RSpec\n\nIn order to test presenters with RSpec, make sure you have `rspec-rails` in your\nGemfile. Given the following presenter:\n\n```ruby\n# app/presenters/posts/show_presenter.rb\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n\n  def body\n    Markdown.render(@post.body)\n  end\nend\n```\n\nYou can test the presenter methods like this:\n\n```ruby\n# You can put this in your `spec_helper.rb`.\nrequire 'curly/rspec'\n\n# spec/presenters/posts/show_presenter_spec.rb\ndescribe Posts::ShowPresenter, type: :presenter do\n  describe \"#body\" do\n    it \"renders the post's body as Markdown\" do\n      assign(:post, double(:post, body: \"**hello!**\"))\n      expect(presenter.body).to eq \"\u003cstrong\u003ehello!\u003c/strong\u003e\"\n    end\n  end\nend\n```\n\nNote that your spec *must* be tagged with `type: :presenter`.\n\n\n### Examples\n\nHere is a simple Curly template – it will be looked up by Rails automatically.\n\n```html\n\u003c!-- app/views/posts/show.html.curly --\u003e\n\u003ch1\u003e{{title}}\u003ch1\u003e\n\u003cp class=\"author\"\u003e{{author}}\u003c/p\u003e\n\u003cp\u003e{{description}}\u003c/p\u003e\n\n{{comment_form}}\n\n\u003cdiv class=\"comments\"\u003e\n  {{comments}}\n\u003c/div\u003e\n```\n\nWhen rendering the template, a presenter is automatically instantiated with the\nvariables assigned in the controller or the `render` call. The presenter declares\nthe variables it expects with `presents`, which takes a list of variables names.\n\n```ruby\n# app/presenters/posts/show_presenter.rb\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n\n  def title\n    @post.title\n  end\n\n  def author\n    link_to(@post.author.name, @post.author, rel: \"author\")\n  end\n\n  def description\n    Markdown.new(@post.description).to_html.html_safe\n  end\n\n  def comments\n    render 'comment', collection: @post.comments\n  end\n\n  def comment_form\n    if @post.comments_allowed?\n      render 'comment_form', post: @post\n    else\n      content_tag(:p, \"Comments are disabled for this post\")\n    end\n  end\nend\n```\n\n\nCaching\n-------\n\nCaching is handled at two levels in Curly – statically and dynamically. Static caching\nconcerns changes to your code and templates introduced by deploys. If you do not wish\nto clear your entire cache every time you deploy, you need a way to indicate that some\nview, helper, or other piece of logic has changed.\n\nDynamic caching concerns changes that happen on the fly, usually made by your users in\nthe running system. You wish to cache a view or a partial and have it expire whenever\nsome data is updated – usually whenever a specific record is changed.\n\n\n### Dynamic Caching\n\nBecause of the way logic is contained in presenters, caching entire views or partials\nby the data they present becomes exceedingly straightforward. Simply define a\n`#cache_key` method that returns a non-nil object, and the return value will be used to\ncache the template.\n\nWhereas in ERB you would include the `cache` call in the template itself:\n\n```erb\n\u003c% cache([@post, signed_in?]) do %\u003e\n  ...\n\u003c% end %\u003e\n```\n\nIn Curly you would instead declare it in the presenter:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  presents :post\n\n  def cache_key\n    [@post, signed_in?]\n  end\nend\n```\n\nLikewise, you can add a `#cache_duration` method if you wish to automatically expire\nthe fragment cache:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  ...\n\n  def cache_duration\n    30.minutes\n  end\nend\n```\n\nIn order to set *any* cache option, define a `#cache_options` method that\nreturns a Hash of options:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  ...\n\n  def cache_options\n    { compress: true, namespace: \"my-app\" }\n  end\nend\n```\n\n\n### Static Caching\n\nStatic caching will only be enabled for presenters that define a non-nil `#cache_key`\nmethod (see [Dynamic Caching.](#dynamic-caching))\n\nIn order to make a deploy expire the cache for a specific view, set the `version` of the\nview to something new, usually by incrementing by one:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  version 3\n\n  def cache_key\n    # Some objects\n  end\nend\n```\n\nThis will change the cache keys for all instances of that view, effectively expiring\nthe old cache entries.\n\nThis works well for views, or for partials that are rendered in views that themselves\nare not cached. If the partial is nested within a view that _is_ cached, however, the\nouter cache will not be expired. The solution is to register that the inner partial\nis a dependency of the outer one such that Curly can automatically deduce that the\nouter partial cache should be expired:\n\n```ruby\nclass Posts::ShowPresenter \u003c Curly::Presenter\n  version 3\n  depends_on 'posts/comment'\n\n  def cache_key\n    # Some objects\n  end\nend\n\nclass Posts::CommentPresenter \u003c Curly::Presenter\n  version 4\n\n  def cache_key\n    # Some objects\n  end\nend\n```\n\nNow, if the `version` of `Posts::CommentPresenter` is bumped, the cache keys for both\npresenters would change. You can register any number of view paths with `depends_on`.\n\nCurly integrates well with the\n[caching mechanism](http://guides.rubyonrails.org/caching_with_rails.html) in Rails 4 (or\n[Cache Digests](https://github.com/rails/cache_digests) in Rails 3), so the dependencies\ndefined with `depends_on` will be tracked by Rails. This will allow you to deploy changes\nto your templates and have the relevant caches automatically expire.\n\n\nThanks\n------\n\nThanks to [Zendesk](http://zendesk.com/) for sponsoring the work on Curly.\n\n\n### Contributors\n\n- Daniel Schierbeck ([@dasch](https://github.com/dasch))\n- Benjamin Quorning ([@bquorning](https://github.com/bquorning))\n- Jeremy Rodi ([@medcat](https://github.com/medcat))\n- Alisson Cavalcante Agiani ([@thelinuxlich](https://github.com/thelinuxlich))\n- Łukasz Niemier ([@hauleth](https://github.com/hauleth))\n- Cristian Planas ([@Gawyn](https://github.com/Gawyn))\n- Steven Davidovitz ([@steved](https://github.com/steved))\n\n\nBuild Status\n------------\n\n[![Build Status](https://github.com/zendesk/curly/workflows/CI/badge.svg)](https://github.com/zendesk/curly/actions?query=workflow%3ACI)\n\nCopyright and License\n---------------------\n\nCopyright (c) 2013 Daniel Schierbeck (@dasch), Zendesk Inc.\n\nLicensed under the [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fcurly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Fcurly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fcurly/lists"}