0.0
No commit activity in last 3 years
No release in over 3 years
With PrismicRails it is simple to query the prismic.io API for a defined custom type. By providing rails helpers the integration in your rails view is much easier as before.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 2.2, >= 2.2.1
~> 0.10.4
~> 13.0
~> 5.1, >= 5.1
~> 3.0
~> 0.14, >= 0.14.1
~> 3.0.3, >= 3.0.3
~> 3.0, >= 3.0.1

Runtime

~> 1.5, >= 1.5
>= 4.2
 Project Readme

PrismicRails

Gem Version Build Status Code Climate

Library to consume API-based CMS prismic.io and to display fetched content into your Rails app.

This gem uses prismicio/ruby-kit gem to consume Prismic API.

Installation

Add this line to your application's Gemfile:

gem 'prismic_rails', git: 'git@github.com:fadendaten/prismic_rails.git'

And then execute:

$ bundle

Configuration

Copy the initializer file by running

$ rails g prismic_rails:install

And then set the ENV variables you got from prismic.io.

I18n Support

prismic.io supports finer graded set of locals. To work with that we need to map Rails locale to the locale prismic.io recognise. Define the language hash as following:

config.languages = {
  'en' => 'en-gb',
  'de' => 'de-ch',
  'fr' => 'fr-ch',
  'it' => 'it-ch',
  }

No need to configure language hash if you don't want I18n support. English will be used by default.

Caching

PrismicRails uses Rails caching to fasten the query process. You can choose to usse it or not to use it.

$ config.caching = true

Usage

From any view of your application we can do the followings:

Query the prismic type 'blog-post' and render each document as html

<%= prismic_type 'blog-post' do |result| %>
  <%- result.documents.each do |document| %>
    <%= document.to_html %>
  <% end %>
<% end %>

Query the prismic type 'blog-post' in english

<%= prismic_type 'blog-post', lang: 'en' do |result| %>
  <%- result.documents.each do |document| %>
    <%= document.to_html %>
  <% end %>
<% end %>

Query only the title of the type 'blog-post

<%= prismic_type 'tea' do |result| %>
  <%= result.find_fragment('title').to_html %>
<% end %>

You can use to_text is case you want only the text.

License

The gem is available as open source under the terms of the MIT License.