YAML 1.2 parser and serializer for JavaScript
Created
October 15, 2017 08:07
-
-
Save jameswquinn/591410f11b3e9a7291bb6e51d10ec7ee to your computer and use it in GitHub Desktop.
JS-YAML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div.container ng-app="codepen" | |
| div.row | |
| div.col-md-12 | |
| h1.page-header Unofficial JS-YAML demo. YAML JavaScript parser. | |
| div.row ng-controller="MainCtrl" | |
| div.col-md-6 | |
| div.panel.panel-default | |
| div.panel-heading Source | |
| div.panel-body | |
| form role="form" | |
| textarea.form-control ng-model="source" | |
| div.col-md-6 | |
| div.panel.panel-default | |
| div.panel-heading Result | |
| div.panel-body | |
| pre.pre-scrollable | |
| | {{ safeLoad(source) | json }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app = angular.module('codepen', []) | |
| app.controller 'MainCtrl', ($scope, $http) -> | |
| $scope.safeLoad = (string) -> | |
| try | |
| jsyaml.safeLoad string | |
| catch error | |
| error.stack || String(error) | |
| yaml = 'https://codepen.io/wulab/pen/aAnHc.html' | |
| $http.get(yaml).success (data) -> | |
| $scope.source = data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script> | |
| <script src="//cdnjs.cloudflare.com/ajax/libs/js-yaml/3.4.2/js-yaml.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .page-header { | |
| padding-bottom: 9px; | |
| margin: 40px 0 20px; | |
| border-bottom: 1px solid #eee; | |
| } | |
| textarea { | |
| font-family: monospace; | |
| .panel-body & { | |
| height: 500px; | |
| } | |
| } | |
| pre { | |
| overflow: auto; | |
| word-wrap: normal; | |
| white-space: pre; | |
| .panel-body & { | |
| margin-bottom: 0; | |
| height: 500px; | |
| } | |
| &.pre-scrollable { | |
| /* reset max-height to set height */ | |
| max-height: none; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment