{"id":26967083,"url":"https://github.com/yb66/sinatra-partial","last_synced_at":"2025-04-09T12:41:07.783Z","repository":{"id":1556431,"uuid":"1951154","full_name":"yb66/Sinatra-Partial","owner":"yb66","description":"Just the partials helper in a gem. That is all.","archived":false,"fork":false,"pushed_at":"2017-07-28T18:23:23.000Z","size":89,"stargazers_count":105,"open_issues_count":3,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T08:41:08.455Z","etag":null,"topics":["rendering","ruby","sinatra"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"marcgibbons/django-rest-swagger","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yb66.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGES.markdown","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-06-25T06:02:01.000Z","updated_at":"2024-02-21T04:56:29.000Z","dependencies_parsed_at":"2022-07-07T14:31:51.328Z","dependency_job_id":null,"html_url":"https://github.com/yb66/Sinatra-Partial","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yb66%2FSinatra-Partial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yb66%2FSinatra-Partial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yb66%2FSinatra-Partial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yb66%2FSinatra-Partial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yb66","download_url":"https://codeload.github.com/yb66/Sinatra-Partial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045216,"owners_count":21038552,"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":["rendering","ruby","sinatra"],"created_at":"2025-04-03T08:38:34.626Z","updated_at":"2025-04-09T12:41:07.767Z","avatar_url":"https://github.com/yb66.png","language":"Ruby","readme":"## Sinatra Partial ##\n\nPartials for Sinatra!\n\n### Build status ###\n\nMaster branch:\n[![Build Status](https://secure.travis-ci.org/yb66/Sinatra-Partial.png?branch=master)](http://travis-ci.org/yb66/Sinatra-Partial)\n\nDevelop branch:\n[![Build Status for development branch](https://secure.travis-ci.org/yb66/Sinatra-Partial.png?branch=develop)](http://travis-ci.org/yb66/Sinatra-Partial)\n\n### Quick note ###\n\nIf you do decide to use this gem, please let me know if it isn't working for you - make a contribution! Github makes it so simple..! See the [Contribution section](#Contributing) for more.\n\nBack to our previously scheduled programming...\n\n### Por qué? ###\n\nYou may say \"why is this needed?\".\n\nGo on then.\n\n_huff_ \"Why is this needed?\"\n\nBecause I was forever copying the code I took from http://www.sinatrarb.com/faq.html#partials into each and every project. It may well be that this is included in some other gem full of useful helpers, but I haven't found it yet, and besides _this is what I really want_. The whole point of Sinatra is not to get a lot of stuff you didn't really need anyway.\n\nSo here it is, partials, and that's it.\n\n### Installation ###\n\n    gem install sinatra-partial\n\n### Getting started ###\n\nAt the top of your app.rb:\n\n    require 'sinatra/partial'\n\nFor a classic app, that's all you need to do. For a modular app you should register it too:\n\n    class Blah \u003c Sinatra::Base\n      register Sinatra::Partial\n\n\n### Configuration options ###\n\nThe default templating engine is haml. If you wish to use something else, you can set in the config options:\n\n    set :partial_template_engine, :erb\n\nIf you wish, you can also pass this in with the options hash to partial (if you do, it will override the above setting for that call):\n\n    partial(:\"meta/news\", :template_engine =\u003e :erb)\n\nIf you like the Rails convention of adding an underscore to the beginning of a partial, set it here:\n\n    enable :partial_underscores\n\nOtherwise, the default is for no underscore (if you like Rails you know where to get it;)\n\n*Note:*  \n\nIf you're using [Slim](https://rubygems.org/gems/slim) then there are examples in the examples directory, but the output is slightly different for some reason and [the project maintainers don't wish to be helpful](https://github.com/stonean/slim/issues/328). I don't use Slim, if you do then feel free to contribute and find out how to get the specs to pass, but I won't be pursuing this.\n\n### Some examples ###\n\nThe docs are good to look at (big thanks to Sam Elliot for improving them a lot), just follow the docs link from this page if you can't find them:\n\nhttps://rubygems.org/gems/sinatra-partial\n\nor use yard/rdoc to generate them.\n\n\n#### Inside a route ####\n\n    get \"/\" do\n      output = \"\"\n      output \u003c\u003c partial( :top )\n      output \u003c\u003c partial( :middle )\n      output \u003c\u003c partial( :bottom )\n      output\n    end\n    \n    -# top.haml\n    %h2\n      The is the top\n      \n    -# middle.haml\n    %p\n      Can you guess what I am yet?\n    \n    -# bottom.haml\n    %p\n      Is it worse to be at the bottom or the foot?\n\n\n#### Local variables ####\n\n    get \"/\" do\n      output = \"\"\n      @title = \"My contrived example\"\n      username = current_user.username\n      output \u003c\u003c partial( :left_col )\n      output \u003c\u003c partial( :middle, :locals =\u003e { username: username} )\n      output \u003c\u003c partial( :right )\n      output\n    end\n    \n    -# middle.haml\n    %p\n      Wow, here is that #{username} you just passed me!  \n      :-o\n    \n    \n#### Here's one using views ####\n\nRemember that since this is a helper method it can be called inside routes and views - use it where you need it!\n\n    -# welcome_message.haml\n    %h2\n      Welcome back #{username}\n      \n    -# content.haml\n    Blah Blah Blah\n      \n    -# footer.haml\n    You've reached the bottom of the page!\n    \n    -# layout.haml\n    %html\n      %head\n      %body\n        #header\n          = partial :welcome_message, locals: {username: \"Iain\" }\n\n        #main\n          = partial :content\n          \n          = yield\n          \n        #footer\n          = partial :footer        \n        \n\n### Collections ###\n        \nHere's how to use a collection, in this case to render a menu:\n\n    # app.rb\n    \n    before do\n      @menu = [\n                [\"home\", uri(\"/\")],\n                [\"login\", uri(\"/login\")],\n                [\"contact_us\", uri(\"/contact-us\")],\n                [\"about\", uri(\"/about\")], \n             ]\n    end\n           \n    \n    -# menu.haml\n    #nav\n      %ul\n        = partial :menu_item, collection: menu\n      \n    -# menu_item.haml\n    - display_name, url = menu_item\n    - atts ||= {}\n    -# set the class of the  list item for the current page to 'active'\n    - (atts[:class] = atts[:class].nil? ? \"active\" : \"#{atts[:class]} active\") if request.url == url\n    \n    %li{ atts }\n      %a{ class: \"nav\", href: menu_item.last }\n        = menu_item.first\n\n      \n    -# layout.haml\n    %html\n      %head\n        %title= @title\n      %body\n        = yield\n        \n        = partial :menu, locals: { menu: @menu }\n      \n    \nYou'll get a menu built for you.\n\n\n### Examples ###\n\nLook in the examples directory for some very simple examples.\n\n\n### Thanks ###\n\nThanks to Chris Schneider and Sam Elliott for sharing their code, and for sharing further updates.\n\n\n### Contributing ###\n\nMost of all, remember that **any** contribution you can make will be valuable, whether that is putting in a ticket for a feature request (or a bug, but they don't happen here;), cleaning up some grammar, writing some documentation (or even a blog post, let me know!) or a full blooded piece of code - it's **all** welcome and encouraged.\n\nTo contribute some code:\n\n1. Fork this.\n* `git clone git@github.com:YOUR_USERNAME/Sinatra-Partial.git`\n* `git remote add upstream git://github.com/yb66/Sinatra-Partial.git`\n* `git fetch upstream`\n* `git checkout develop`\n* Decide on the feature you wish to add.\n    - Give it a snazzy name, such as kitchen_sink.\n    - `git checkout -b kitchen_sink`\n* Install Bundler.\n    - `gem install bundler -r --no-ri --no-rdoc`\n* Install gems from Gemfile.\n    - `bundle install --binstubs --path vendor`\n    - Any further updates needed, just run `bundle install`, it'll remember the rest.\n* Write some specs.\n* Write some code. (Yes, I believe that is the correct order, and you'll never find me doing any different;)\n* Write some documentation using Yard comments - see http://rubydoc.info/docs/yard/file/docs/GettingStarted.md\n  - Use real English (i.e. full stops and commas, no l33t or LOLZ). I'll accept American English even though it's ugly. Don't be surprised if I 'correct' it.\n  - Code without comments won't get in, I don't have the time to work out what you've done if you're not prepared to spend some time telling me (and everyone else).\n* Run `reek PATH_TO_FILE_WITH_YOUR_CHANGES` and see if it gives you any good advice. You don't have to do what it says, just consider it.\n* Run specs to make sure you've not broken anything. If it doesn't pass all the specs it doesn't get in.\n  - Have a look at coverage/index.htm and see if all your code was checked. We're trying for 100% code coverage.\n  - If your commit changes the way things work or adds a feature then add an example in the examples dir. The specs run off the examples to make sure the library works with a real project while keeping the examples up to date, so make sure you add something there if needs be.\n* Run `bin/rake docs` to generate documentation.\n    - Open up docs/index.html and check your documentation has been added and is clear.\n* Add a short summary of your changes to the top of CHANGES file. Add your name and a link to your bio/website if you like too. **Don't** add a version number, I'll handle that.\n* Send me a pull request.\n    - Don't merge into the develop branch!\n    - Don't merge into the master branch!\n    - see http://nvie.com/posts/a-successful-git-branching-model/ for more on how this is supposed to work.\n* Wait for worldwide fame.\n* Shrug and get on with you life when it doesn't arrive, but know you helped quite a few people in their life, even in a small way - 1000 raindrops will fill a bucket!","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyb66%2Fsinatra-partial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyb66%2Fsinatra-partial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyb66%2Fsinatra-partial/lists"}