{"id":13612265,"url":"https://github.com/rustygeldmacher/jekyll-contentblocks","last_synced_at":"2025-04-13T11:31:53.889Z","repository":{"id":7258116,"uuid":"8570029","full_name":"rustygeldmacher/jekyll-contentblocks","owner":"rustygeldmacher","description":"A Jekyll plugin giving you something like Rails' content_for","archived":false,"fork":false,"pushed_at":"2019-04-29T19:09:45.000Z","size":44,"stargazers_count":149,"open_issues_count":7,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-25T04:44:24.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rustygeldmacher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-05T02:06:54.000Z","updated_at":"2024-01-31T14:11:26.000Z","dependencies_parsed_at":"2022-08-20T23:10:14.917Z","dependency_job_id":null,"html_url":"https://github.com/rustygeldmacher/jekyll-contentblocks","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/rustygeldmacher%2Fjekyll-contentblocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustygeldmacher%2Fjekyll-contentblocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustygeldmacher%2Fjekyll-contentblocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustygeldmacher%2Fjekyll-contentblocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustygeldmacher","download_url":"https://codeload.github.com/rustygeldmacher/jekyll-contentblocks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248705720,"owners_count":21148583,"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":[],"created_at":"2024-08-01T20:00:25.920Z","updated_at":"2025-04-13T11:31:53.370Z","avatar_url":"https://github.com/rustygeldmacher.png","language":"Ruby","funding_links":[],"categories":["Tags","Ruby"],"sub_categories":[],"readme":"# jekyll-contentblocks\n\nCicleCI build: [![CircleCI](https://circleci.com/gh/rustygeldmacher/jekyll-contentblocks.svg?style=svg)](https://circleci.com/gh/rustygeldmacher/jekyll-contentblocks)\n\nGives you a mechanism in Jekyll to pass content up from pages into their parent\nlayouts. It's kind of like having Rails' content_for available for Jekyll.\n\n## Installation\n\njekyll-contentblocks supports Jekyll 2.3.0 and above. Any other version below\n2.3.0 is not guaranteed to work.\n\n### Bundler (recommended)\n\nAdd this line to your Jekyll project's `Gemfile`:\n```ruby\n group :jekyll_plugins do\n   gem 'jekyll-contentblocks'\n end\n```\n\nThen execute:\n```bash\n$ bundle install\n```\n\n### Standalone\n\nExecute:\n```bash\n$ gem install jekyll-contentblocks\n```\n\nAnd initialize it in a plugin:\n```ruby\n# _plugins/ext.rb\nrequire \"rubygems\"\nrequire \"jekyll-contentblocks\"\n```\n\n## Usage\n\nIn your layout files, define `contentblock` blocks that say where content will\nend up. For example, say the file `_layouts/default.html` looks like this:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    {% contentblock scripts %}\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv class=\"main\"\u003e\n      {{ content }}\n    \u003c/div\u003e\n    \u003cdiv class=\"sidebar\"\u003e\n      {% contentblock sidebar %}\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nNow to add content to the sidebar from a post, you'd just need to do something like:\n\n```html\n---\nlayout: default\n---\n\nHere is my post content.\n\n{% contentfor sidebar %}\n* Some content\n* in a markdown list\n* with some {{ 'liquid' }} tags too!\n{% endcontentfor %}\n```\n\nNote that we didn't add anything to the `scripts` block in the post. That's OK,\ncontent blocks without any content will be ignored.\n\n### Skipping content conversion in a block\n\nBy default, a content block will be run through the converter for the current\nfile (Markdown, for instance). Sometimes this is not desirable, such as for\nblocks containing code that shouldn't be modified. In the example above, content\nin the `scripts` block will be converted by default. To prevent this, add the\n`no-convert` option to the block, like this:\n\n```\n{% contentblock scripts no-convert %}\n```\n\nNow any content added to `scripts` will be placed in the block without any\nformatting applied.\n\n### Checking if a block has content\n\nWe might want to check if the particular contentblock has content before using\nit in our template. To do this, use the `ifhascontent` tag:\n\n```liquid\n{% ifhascontent javascripts %}\n  \u003cscript type=\"text/javascript\"\u003e\n    {% contentblock javascripts %}\n  \u003c/script\u003e\n{% endifhascontent %}\n```\n\nSimilarly, there's the opposite tag, `ifnothascontent`:\n\n```liquid\n{% ifnothascontent sidebar %}\n  \u003cdiv\u003e\n    This is our default sidebar.\n  \u003c/div\u003e\n{% endifnothascontent %}\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n### Running the tests\n\nTry to make sure that your changes work with all of the latest point releases\nof Jekyll. To do this, run the test suite:\n\n```bash\n\u003e bundle\n\u003e bundle exec appraisal install\n\u003e bundle exec appraisal rpsec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustygeldmacher%2Fjekyll-contentblocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustygeldmacher%2Fjekyll-contentblocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustygeldmacher%2Fjekyll-contentblocks/lists"}