GithubHelp home page GithubHelp logo

myleslee / java-premailer-wrapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdedetrich/java-premailer-wrapper

0.0 2.0 0.0 11 KB

Java wrapper for Premailer

License: Other

Java 78.73% Ruby 21.27%

java-premailer-wrapper's Introduction

Java Premailer Wrapper

What is this?

This java wrapper around Premailer. It is roughly based on the wrapper from here, with a few important differences

  • It works
  • Premailer is brought in as a dependency rather than being directly included in the source. This allows you to easily bump Premailer as a dependency
  • Added a method that allows you to terminate a Premailer instance (PremailerInterface.destroyInstance)
  • A fix for JDK 1.8 in regards to conflicts for .merge method (see here)
  • The Premailer class no longer acts like a pseudo singleton. Its up to the user to manage the instance (typically you would store this in a Singleton to reuse the PremailerInstance)
  • Uses a versioning scheme to identify between Premailer releases, i.e. 1.0_1.8.7 means version 1 using Premailer 1.8.7

Dependency Info

Currently hosted on maven central, with the following details

<dependency>
	  <groupId>org.mdedetrich</groupId>
	  <artifactId>java-premailer-wrapper</artifactId>
	  <version>1.1_1.8.7</version>
</dependency>

If you haven't already done so, you need to add the Rubygems maven repository, i.e.

<repository>
    <id>rubygems-releases</id>
    <url>http://rubygems-proxy.torquebox.org/releases</url>
</repository>

Building

You can build a jar by doing

mvn compile
mvn package

Usage

To use, do something like this

String testHtml = "<html><head></head><body><p>test</p></body></html>";

// Create a Premailer
Premailer premailer = new Premailer()

// Get the instance
PremailerInterface premailerInterface = premailer.getPremailerInstance();
    
// Pass your options in form of HashMap
Map<String, Object> options = new HashMap<String, Object>( );
    
// Pass at least this option for html string
options.put( "with_html_string", true );
    
// Initialize premailer with html and options
premailerInterface.init( testHtml, options );
    
System.out.print( premailerInterface.plain_text( ) );
System.out.print( premailerInterface.inline_css( ) );
    
// Shut it down
premailer.destroyInstance();     

java-premailer-wrapper's People

Contributors

enalmada avatar jontsai avatar mdedetrich avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.