File tree Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Do you use Angular? Are you tired of putting your templates in separate files or
3
3
4
4
With the angular-jsx library you can use JSX directly in your directives. JSX templates are converted to strings that Angular can understand.
5
5
6
- ## Example
6
+ ## Example 1
7
7
### Input
8
8
```
9
9
angular.module("foo").directive("bar",
@@ -24,6 +24,34 @@ angular.module("foo").directive("bar",
24
24
}
25
25
);
26
26
```
27
+ ## Example 2
28
+ ### Input
29
+ ```
30
+ angular.module("foo").directive("bar",
31
+ function() {
32
+ return {
33
+ template: (
34
+ <div>
35
+ <h1>Multi-line example</h1>
36
+ <div class="bar">This is a bit more <em>advanced</em>.</div>
37
+ </div>
38
+ )
39
+ }
40
+ }
41
+ );
42
+ ```
43
+ ### Output
44
+ ```
45
+ angular.module("foo").directive("bar",
46
+ function() {
47
+ return {
48
+ template: (
49
+ "<div>\n <h1>Multi-line example</h1>\n <div class=\"bar\">This is a bit more <em>advanced</em>.</div>\n</div>"
50
+ )
51
+ }
52
+ }
53
+ );
54
+ ```
27
55
## Usage
28
56
```
29
57
var angularjsx = require("angular-jsx");
Original file line number Diff line number Diff line change
1
+ angular . module ( "foo" ) . directive ( "bar" ,
2
+ function ( ) {
3
+ return {
4
+ template : (
5
+ < div >
6
+ < h1 > Multi-line example</ h1 >
7
+ < div class = "bar" > This is a bit more < em > advanced</ em > .</ div >
8
+ </ div >
9
+ )
10
+ }
11
+ }
12
+ ) ;
Original file line number Diff line number Diff line change
1
+ angular . module ( "foo" ) . directive ( "bar" ,
2
+ function ( ) {
3
+ return {
4
+ template : (
5
+ "<div>\n <h1>Multi-line example</h1>\n <div class=\"bar\">This is a bit more <em>advanced</em>.</div>\n</div>"
6
+ )
7
+ }
8
+ }
9
+ ) ;
Original file line number Diff line number Diff line change @@ -30,10 +30,14 @@ describe("angularjsx", function () {
30
30
it ( "should handle parentheses" , function ( ) {
31
31
assert . equal ( angularjsx . convert ( "var x = {template: (<br/>)}" ) , "var x = {template: (\"<br/>\")}" ) ;
32
32
} ) ;
33
- it ( "should parse Angular directive" , function ( ) {
33
+ it ( "should parse simple template in Angular directive" , function ( ) {
34
34
assertFixture ( 0 ) ;
35
35
} ) ;
36
36
37
+ it ( "should parse multi-line template in Angular directive" , function ( ) {
38
+ assertFixture ( 1 ) ;
39
+ } ) ;
40
+
37
41
function assertFixture ( index ) {
38
42
var fs = require ( "fs" ) ;
39
43
You can’t perform that action at this time.
0 commit comments