Project

docomo_css

0.01
No commit activity in last 3 years
No release in over 3 years
Inlines CSS so that you can use external CSS with docomo handsets.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0

Runtime

 Project Readme

docomo_css is a CSS in-liner.

Most handsets for the Japanese cell-phone carrier DoCoMo cannot use external style sheets, such as

<link rel="stylesheet" /> style css, only can use in-line CSS.

Instead, every element must use its own style attribute, for example

<div style="font-size:x-small">

docomo_css works around this by inlining all CSS automatically for you.

Also, docomo does not support styling some elements such as h1, but does if you nest the contents in a span or div. This library automatically handles transforming of markup such as

<h1>foo</h1>

to

<h1><span style="font-size:x-small">foo</span></h1>

so you don’t need to change any styling. If you were doing this manually before and don’t want docomo_css to automatically update your html, use

docomo_css inject_unsupported_style: false

Install¶ ↑

sudo gem install docomo_css

Requirements¶ ↑

* Rails 4

Usage¶ ↑

# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
  docomo_filter  # please add this
  ...
end

# app/views/articles/index.html.erb
<html>
<head>
  <%= stylesheet_link_tag 'foo', media: 'handheld, tty' %>
</head>
<body>
  <div class="title">bar</div>
</body>
</html>

# public/stylesheets/foo.css
.title {
  color: red;
}

# result
<html>
<head></head>
<body>
  <div class="title" style="color:red">bar</div>
</body>
</html>

Options for the value of this docomo_css are

* mobile - always transform css when content type is application/xhtml+xml, default false
* xml_declare - add xml declaration, default true

Author¶ ↑

Copyright © 2008-2014 milk1000cc & Paul McMahon, released under the MIT license

milk1000cc <info@milk1000.cc>

Paul McMahon <paul@mobalean.com>