Socket
Socket
Sign inDemoInstall

ember-code-prettify

Package Overview
Dependencies
228
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ember-code-prettify

Ember.js addon for using Google Code Prettify syntax highlighting


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Ember Code Prettify Download count all time npm

Ember Code Prettify exposes a service to render Google Code Prettify syntax highlighting in Ember.js applications.

Installation

ember install ember-code-prettify

Configuration

With no configuration, Ember Code Prettify will use the default skin and languages. The following config imports the css & yaml languages extensions and uses the desert skin:

// config/environment.js
ENV['ember-code-prettify'] = {
  languages: ['css', 'yaml'],
  skin: 'desert'
};

Usage

Ember Code Prettify exposes a service codePrettify. It can be used to paint the syntax highlighting in routes and components.

Firstly ensure your code snippet is formatted like so:

<pre class="prettyprint lang-js">
  console.log('This will be painted');
</pre>

Then get prettify to render using:

get(this, 'codePrettify').prettify();

Routes

If code snippets are added statically to a route template, simply fire Ember Code Prettify in an afterRender hook.

import Route from '@ember/routing/route';
import { get } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';
import { inject } from '@ember/service';

export default Route.extend({
  codePrettify: inject(),

  init() {
    scheduleOnce('afterRender', this, function() {
      get(this, 'codePrettify').prettify();
    });
  }
});

Components

For code snippets added to component templates, use the didRender hook. Be warned, this hook will fire on any subsequent render of the component.

import Component from '@ember/component';
import { get } from '@ember/object';
import { inject } from '@ember/service';

export default Component.extend({
  codePrettify: inject(),

  didRender() {
    get(this, 'codePrettify').prettify();
  }
});

Contributing

Installation

  • git clone <repository-url> this repository
  • cd ember-code-prettify
  • npm install

Test App

Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Keywords

FAQs

Last updated on 12 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc