我正在尋找一个JavaScript yAML解析器,它將yAML轉換為HTML頁面中可用的內容.我已经在Github( https://github.com/visionmedia/js-yaml )上尝試了此版本, 就像它只適用於node.js
我應该使用哪个庫,是否有任何示例代碼来顯示示例用法?
最新回復
- 5月前1 #
- 5月前2 #
這是我發現的.不確定该满足多少規格,但是否满足我的需求。
https://github.com/jeremyfa/yaml.js
- 5月前3 #
很抱歉迴答了一个旧帖子,但我遇到了与您相同的問题。
没有一个可用的javascript yAML解析器可以满足我的需求,因此我開發了自己的: 可以在這裏找到:http://code.google.com/p/javascript-yaml-parser/
希望對別人有帮助:)
球, Diogo
- 5月前4 #
js-yaml在OSX上的Safari,Chrome和Firefox中可以正常工作.這是一个例子。
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="fr"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Test js-yaml</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="./js-yaml/dist/js-yaml.min.js"></script> <script type="text/javascript"> // YAML string to Javascript object var obj = jsyaml.load( 'greeting: hello\nname: world' ); console.log( obj ); // YAML file to Javascript object $.get( 'https://raw.githubusercontent.com/nodeca/js-yaml/c50f9936bd1e99d64a54d30400e377f4fda401c5/benchmark/samples/document_application2.yaml', function( data ) { var obj = jsyaml.load( data ); console.log( obj ); }); // Huge YAML file (7.2 MB) to Javascript object $.get( 'https://raw.githubusercontent.com/nodeca/js-yaml/master/benchmark/samples/document_huge.yaml', function( data ) { var obj = jsyaml.load( data ); console.log( obj ); }); </script> </head> <body> <h1>Test js-yaml</h1> <p><a href="https://github.com/nodeca/js-yaml">https://github.com/nodeca/js-yaml</a></p> </body> </html>
相似問題
- javascript:仅使用網址而不打開新視窗来print網頁?javascripthtml2021-01-11 23:26
- javascript:在文字區域或文字輸入中多色文字突出顯示javascripthtmlcsshtml5css32021-01-11 23:28
- javascript:从另一个頁面获取Bootstrap的模式內容javascriptjqueryhtmltwitterbootstrapmodaldialog2021-01-11 22:55
- javascript:通過單击外部關闭divjavascriptjqueryhtml2021-01-11 22:24
- javascript:為什麼某些技術上可序列化的輸入屬性不能序列化?javascripthtmldom2021-01-11 13:56
JS-yAML解析器可在瀏覽器中工作.這是線上演示http://nodeca.github.com/js-yaml/.虽然,它的主要目標是node.js,但瀏覽器版本只是為了好玩而已:)