Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test React.rb editable single page app file
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Inline Reactive Ruby Demo</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="inline-reactive-ruby.js" />
<STYLE type="text/css">
H1.myclass {border-width: 1; border: solid; text-align: center}
</STYLE>
<!-- scripts can be remote or inline -->
<script type="text/ruby">
class Clock < React::Component::Base
before_mount do
state.time! Time.now
every(1) { state.time! Time.now }
end
def render
"The time is #{state.time}"
end
end
</script>
<script type="text/ruby">
Element["body"].render { Clock() }
</script>
</head>
<body>
<div id="clock"></div>
<div>The time brought to you by <a href="https://github.com/reactive-ruby/inline-reactive-ruby">inline-reactive-ruby</a></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.