aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/core/converter/new-line-to-br-converter.js
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/core/converter/new-line-to-br-converter.js
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/core/converter/new-line-to-br-converter.js')
-rwxr-xr-xnode_modules/montage/core/converter/new-line-to-br-converter.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/node_modules/montage/core/converter/new-line-to-br-converter.js b/node_modules/montage/core/converter/new-line-to-br-converter.js
new file mode 100755
index 00000000..d64531e6
--- /dev/null
+++ b/node_modules/montage/core/converter/new-line-to-br-converter.js
@@ -0,0 +1,60 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module montage/core/converter/new-line-to-br-converter
8 @requires montage/core/core
9 @requires montage/core/converter/converter
10*/
11
12var Montage = require("montage").Montage;
13var Converter = require('core/converter/converter').Converter;
14
15/**
16 Replaces all new line characters with a HTML &lt;br&gt;
17 @memberof module:montage/core/converter#
18 @function
19 @param {String} str The string to format.
20 @returns {String} The formatted string.
21 */
22var newLineToBr = function(str) {
23 return str.replace(/(\r\n|\r|\n)/g, '<br />');
24};
25
26/**
27 @class module:montage/core/converter/new-line-to-br-converter.NewLineToBrConverter
28 @classdesc Converts a newline to a &lt;br&gt; tag.
29 */
30exports.NewLineToBrConverter = Montage.create(Converter, /** @lends module:montage/core/converter/new-line-to-br-converter.NewLineToBrConverter# */{
31
32 /**
33 @private
34 */
35 _convert: {
36 value: function(v) {
37 if (v && typeof v === 'string') {
38 return newLineToBr(v);
39 }
40 return v;
41 }
42 },
43 /**
44 @function
45 @param {String} v Case format
46 @returns this._convert(v)
47 */
48 convert: {value: function(v) {
49 return this._convert(v);
50 }},
51
52 /**
53 @function
54 @param {String} v Case format
55 @returns this._convert(v)
56 */
57 revert: {value: function(v) {
58 return this._convert(v);
59 }}
60});