Sha256: b3dbc9a57c3d81173e8a8924d5c2c18e32a9a13fd1bd017cbcef1c8fa6beb489
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
# Content Block Tools A suite of tools for working with GOV.UK Content Blocks ## Installation Install the gem gem install content_block_tools or add it to your Gemfile gem "content_block_tools" ## Usage ### Finding embed code To find embed code in a block of text, use `ContentBlockReference.find_all_in_document`: ```ruby content = "Hello - here is a embed code {{embed:content_block_email_address:be24ee44-b636-4a3e-b979-0da27b4a8e62}}" ContentBlockReference.find_all_in_document(content) # => #[#<data ContentBlockTools::ContentBlockReference # document_type="content_block_email_address", # content_id="be24ee44-b636-4a3e-b979-0da27b4a8e62", # embed_code="{{embed:content_block_email_address:be24ee44-b636-4a3e-b979-0da27b4a8e62}}">] ``` ### Rendering a content block To render a content block, you can initialize the content block like so: ```ruby content_block = ContentBlockTools::ContentBlock.new( document_type: "something", content_id: "some uuid", title: "Title", details: { some: "hash"}, ) ``` Then call `render`: ```ruby content_block.render #=> {HTML representation of content block} ``` For more information, see the [Documentation](https://www.rubydoc.info/github/alphagov/content_block_tools) ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
content_block_tools-0.3.0 | README.md |
content_block_tools-0.2.1 | README.md |
content_block_tools-0.2.0 | README.md |
content_block_tools-0.1.0 | README.md |