{"id":29955019,"url":"https://github.com/foca/sinatra-content-for","last_synced_at":"2025-08-03T17:09:21.738Z","repository":{"id":563653,"uuid":"194728","full_name":"foca/sinatra-content-for","owner":"foca","description":"Sinatra extension to use a `content_for` helper similar to Rails' – Don't use it, use Sinatra::Contrib instead.","archived":false,"fork":false,"pushed_at":"2014-03-20T05:39:28.000Z","size":137,"stargazers_count":66,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-04-10T10:20:05.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/sinatra/sinatra-contrib","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foca.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-05-07T05:59:28.000Z","updated_at":"2019-08-13T14:24:35.000Z","dependencies_parsed_at":"2022-07-28T22:29:09.897Z","dependency_job_id":null,"html_url":"https://github.com/foca/sinatra-content-for","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"purl":"pkg:github/foca/sinatra-content-for","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fsinatra-content-for","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fsinatra-content-for/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fsinatra-content-for/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fsinatra-content-for/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foca","download_url":"https://codeload.github.com/foca/sinatra-content-for/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fsinatra-content-for/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268578914,"owners_count":24273089,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-03T17:09:14.263Z","updated_at":"2025-08-03T17:09:21.731Z","avatar_url":"https://github.com/foca.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= This project is no longer maintained. See http://github.com/sinatra/sinatra-contrib\n\nSinatra::Contrib is a project maintained by the sinatra core team that packages\nseveral small widely used extensions, such as content_for. Please install that\nas that is actively maintained and compatibility is ensured with all future\nversions of sinatra.\n\n\n= ContentFor\n\nSmall extension for the Sinatra[http://sinatrarb.com] web framework\nthat allows you to use the following helpers in your views:\n\n    \u003c% content_for :some_key do %\u003e\n      \u003cchunk of=\"html\"\u003e...\u003c/chunk\u003e\n    \u003c% end %\u003e\n\n    \u003c% yield_content :some_key %\u003e\n\nThis allows you to capture blocks inside views to be rendered later\nin this request. For example, to populate different parts of your\nlayout from your view.\n\nWhen using this with the Haml rendering engine, you should do the\nfollowing:\n\n    - content_for :some_key do\n      %chunk{ :of =\u003e \"html\" } ...\n\n    = yield_content :some_key\n\n\u003cb\u003eNote\u003c/b\u003e that with ERB \u003ctt\u003eyield_content\u003c/tt\u003e is called \u003cb\u003ewithout\u003c/b\u003e\nan '=' block (\u003ctt\u003e\u003c%= %\u003e\u003c/tt\u003e), but with Haml it uses \u003ctt\u003e= yield_content\u003c/tt\u003e.\n\nUsing an '=' block in ERB will output the content twice for each block,\nso if you have problems with that, make sure to check for this.\n\n== Usage\n\nIf you're writing \"classic\" style apps, then requring \n\u003ctt\u003esinatra/content_for\u003c/tt\u003e should be enough. If you're writing\n\"classy\" apps, then you also need to call \n\u003ctt\u003ehelpers Sinatra::ContentFor\u003c/tt\u003e in your app definition.\n\n== And how is this useful?\n\nFor example, some of your views might need a few javascript tags and\nstylesheets, but you don't want to force this files in all your pages.\nThen you can put \u003ctt\u003e\u003c% yield_content :scripts_and_styles %\u003e\u003c/tt\u003e on\nyour layout, inside the \u003chead\u003e tag, and each view can call \n\u003ctt\u003econtent_for\u003c/tt\u003e setting the appropriate set of tags that should \nbe added to the layout.\n\n== Credits\n\nCode by foca[http://github.com/foca], inspired on the Ruby on Rails\nhelpers with the same name. Haml support by mattly[http://github.com/mattly].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fsinatra-content-for","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoca%2Fsinatra-content-for","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fsinatra-content-for/lists"}