|
1 | 1 | <div data-reactrb-mount="CodeEditor"></div>
|
2 | 2 |
|
| 3 | +<script> |
| 4 | +// var myCodeMirror = CodeMirror(document.body); |
| 5 | +(function() { |
| 6 | + var mode = CodeMirror.getMode({indentUnit: 2}, "ruby"); |
| 7 | + function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } |
| 8 | + |
| 9 | + MT("divide_equal_operator", |
| 10 | + "[variable bar] [operator /=] [variable foo]"); |
| 11 | + |
| 12 | + MT("divide_equal_operator_no_spacing", |
| 13 | + "[variable foo][operator /=][number 42]"); |
| 14 | + |
| 15 | +})(); |
| 16 | +</script> |
| 17 | + |
| 18 | + |
| 19 | +<!doctype html> |
| 20 | + |
| 21 | +<title>CodeMirror: Ruby mode</title> |
| 22 | +<meta charset="utf-8"/> |
| 23 | +<link rel=stylesheet href="../../doc/docs.css"> |
| 24 | + |
| 25 | +<link rel="stylesheet" href="../../lib/codemirror.css"> |
| 26 | +<script src="../../lib/codemirror.js"></script> |
| 27 | +<script src="../../addon/edit/matchbrackets.js"></script> |
| 28 | +<script src="ruby.js"></script> |
| 29 | +<style> |
| 30 | + .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} |
| 31 | + .cm-s-default span.cm-arrow { color: red; } |
| 32 | + </style> |
| 33 | +<div id=nav> |
| 34 | + <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
| 35 | + |
| 36 | + <ul> |
| 37 | + <li><a href="../../index.html">Home</a> |
| 38 | + <li><a href="../../doc/manual.html">Manual</a> |
| 39 | + <li><a href="https://github.com/codemirror/codemirror">Code</a> |
| 40 | + </ul> |
| 41 | + <ul> |
| 42 | + <li><a href="../index.html">Language modes</a> |
| 43 | + <li><a class=active href="#">Ruby</a> |
| 44 | + </ul> |
| 45 | +</div> |
| 46 | + |
| 47 | +<article> |
| 48 | +<h2>Ruby mode</h2> |
| 49 | +<form><textarea id="code" name="code"> |
| 50 | +def polyval(x, coef) |
| 51 | + sum = 0 |
| 52 | + coef = coef.clone # Don't want to destroy the original |
| 53 | + while true |
| 54 | + sum += coef.shift # Add and remove the next coef |
| 55 | + break if coef.empty? # If no more, done entirely. |
| 56 | + sum *= x # This happens the right number of times. |
| 57 | + end |
| 58 | + return sum |
| 59 | +end |
| 60 | +</textarea></form> |
| 61 | + <script> |
| 62 | + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
| 63 | + mode: "text/x-ruby", |
| 64 | + matchBrackets: true, |
| 65 | + indentUnit: 4 |
| 66 | + }); |
| 67 | + </script> |
| 68 | + |
| 69 | + </article> |
| 70 | + |
3 | 71 | ## Pure Ruby
|
4 | 72 | Hyperloop lets you build beautiful interactive user interfaces using the same Ruby language running your server side code. Hyperloop replaces JS code, JSX, HTML, templating languages, and complex frameworks with one simple system.
|
5 | 73 |
|
|
0 commit comments