API Docs for: 0.25.0
Show:

fixstring Class

Custom string field transform that uses the fix-special-char utility function to clean up malformed text sent from the server. This allows string fields to be correctly and transparently used in templates without manually fixing these characters for display on each use.

This transform is used when fixstring is passed as the type parameter to the DS.attr function.

 import DS from 'ember-data';
 export default DS.Model.extend({
    astring: DS.attr('fixstring'),
 });

Item Index

Methods

deserialize

(
  • serialized
  • options
)
When given a serialize value from a JSON object this method must return the deserialized value for the record attribute. Example `javascript deserialize: function(serialized, options) { return empty(serialized) ? null : Number(serialized); } `

Parameters:

  • serialized Object
    The serialized value
  • options Object
    hash of options passed to DS.attr

Returns:

The deserialized value

fixSpecialChar

(
  • inputString
)
String | Null
This function is useful for fixing a bad API behavior. In certain cases the server will insert HTML escape sequences into text, and this will replace &amp; sequences with &, &lt; with < and &gt; with >. Template helper and ember-data field versions of this function are available.

Parameters:

  • inputString String
    A string value to be transformed

Returns:

String | Null:

serialize

(
  • deserialized
  • options
)
When given a deserialized value from a record attribute this method must return the serialized value. Example `javascript serialize: function(deserialized, options) { return Ember.isEmpty(deserialized) ? null : Number(deserialized); } `

Parameters:

  • deserialized Object
    The deserialized value
  • options Object
    hash of options passed to DS.attr

Returns:

The serialized value