项目作者: topbitdu

项目描述 :
Repres (REsource PRESentation) is a series of resource representation engines. The HyperText resource presentation engine includes HyperText-based resource presentation templates & snippets. Repres (资源表现)是一系列的资源表现引擎。超文本资源表现引擎包括基于超文本的资源表现模版和片段。
高级语言: Ruby
项目地址: git://github.com/topbitdu/repres-hyper_text.git
创建时间: 2016-04-22T09:08:43Z
项目社区:https://github.com/topbitdu/repres-hyper_text

开源协议:MIT License

下载


Repres HyperText 超文本资源表现引擎

Documentation
License

Gem Version
Dependency Status

Repres (REsource PRESentation) is a series of resource presentation engines. The Hyper Text resource presentation engine includes HyperText-based resource presentation templates & snippets.
Repres (资源表现)是一系列的资源表现引擎。超文本资源表现引擎包括基于超文本的资源表现模版和片段。

Recent Update

Check out the Road Map to find out what’s the next.
Check out the Change Log to find out what’s new.

Usage in Gemfile

  1. gem 'repres-hyper_text'

Include the Helper in your Application Controller before Render the Style or Script

  1. helper Repres::HyperText::ApplicationHelper

Render the Pre-defined Partials

  1. <html>
  2. <head>
  3. <%= render partial: 'repres/hyper_text/meta' %>
  4. <!-- or the following line works identically -->
  5. <%= hyper_text_meta %>
  6. <%= render partial: 'repres/hyper_text/icon' %>
  7. <!-- or the following line works identically -->
  8. <%= hyper_text_icon %>
  9. <%= render partial: 'repres/hyper_text/style', locals: { options: { 'font-awesome' => true } } %>
  10. <!-- or the following line works identically -->
  11. <%= hyper_text_style 'font-awesome' => true %>
  12. </head>
  13. <body>
  14. <div id='main'></div>
  15. <div id='alpha-dialog'></div>
  16. <div id='beta-dialog'></div>
  17. <div id='gammar-dialog'></div>
  18. <%= render partial: 'repres/hyper_text/script', locals: { options: { jquery: true } } %>
  19. <!-- or the following line works identically -->
  20. <%= hyper_text_script jquery: true %>
  21. </body>
  22. </html>

Render the Meta

The Meta partial includes the HTML meta tags for HTML 5.

  1. <%= render partial: 'repres/hyper_text/meta' %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_meta %>

The source codes of the Meta partial:

  1. <meta charset="UTF-8" />
  2. <meta name="format-detection" content="telephone=no" />
  3. <meta name="msapplication-tap-highlight" content="no" />
  4. <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
  5. <meta name="renderer" content="webkit" />
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge" />

Render the Favorite Icon

The Icon partial includes the HTML link tags for Favorite Icons.

  1. <%= render partial: 'repres/hyper_text/icon',
  2. locals: {
  3. options: {
  4. safari_mask_icon_color: '#5bbad5',
  5. microsoft_application_title_color: '#da532c',
  6. theme_color: '#ffffff'
  7. }
  8. }
  9. %>
  10. <!-- or the following line works identically -->
  11. <%= hyper_text_icon safari_mask_icon_color: '#5bbad5', microsoft_application_title_color: '#da532c', theme_color: '#ffffff' %>

Render the Script

The Script partial includes the HTML script tags. The Boot CDN server is supported by default. However, the :cdn option could be passed in to support other CDN servers. The CDN servers must syncrhonize with cdnjs.

The following code snippet does not load any JavaScript library.

  1. <%= render partial: 'repres/hyper_text/script' %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_script %>

The following code snippet loads the latest jQuery.

  1. <%= render partial: 'repres/hyper_text/script', locals: { options: { jquery: true } } %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_script jquery: true %>

The following code snippet loads the jQuery with the given version.

  1. <%= render partial: 'repres/hyper_text/script', locals: { options: { jquery: { version: '2.2.0', cdn: 'cdn.server.com' } } } %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_script jquery: { version: '2.2.0', cdn: 'cdn.server.com' } %>

The following JavaScript libraries are switchable, and the version can be configurable:

  • :modernizr
  • :jquery
  • :buttons

Render the Style

The Style partial includes the HTML style tags. The Boot CDN server is supported by default. However, the :cdn option could be passed in to support other CDN servers. The CDN servers must syncrhonize with cdnjs.

The following code snippet does not load any CSS library.

  1. <%= render partial: 'repres/hyper_text/style' %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_style %>

The following code snippet loads the latest Font Awesome.

  1. <%= render partial: 'repres/hyper_text/script', locals: { options: { :'font-awesome' => true } } %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_style :'font-awesome' => true %>

The following code snippet loads the Font Awesome with the given version.

  1. <%= render partial: 'repres/hyper_text/style', locals: { options: { :'font-awesome' => { version: '4.4.0', cdn: 'cdn.server.com' } } } %>
  2. <!-- or the following line works identically -->
  3. <%= hyper_text_style :'font-awesome' => { version: '4.4.0', cdn: 'cdn.server.com' } %>

The following CSS libraries are switchable, and the version can be configurable:

  • :’font-awesome’
  • :buttons
  • :’animate.css’

RSpec examples

  1. # spec/models/repres_spec.rb
  2. require 'repres/hyper_text/models_rspec'
  3. # spec/types/repres_spec.rb
  4. require 'repres/hyper_text/types_rspec'
  5. # spec/validators/repres_spec.rb
  6. require 'repres/hyper_text/validators_rspec'