Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Forked from anonymous/converting Google Code
Created March 4, 2012 16:40
Show Gist options
  • Save vendethiel/1973798 to your computer and use it in GitHub Desktop.
Save vendethiel/1973798 to your computer and use it in GitHub Desktop.
sass+cs+haml vs. css+js+html
Translation of Google Maps Code (html + js) to haml + coffeescript
-------------------------------------------------------------------
assets/javascript/application.js
--------------------------------
//
//= require jquery
//= require jquery_ujs
//= require_tree .
assets/javascript/maps.js.coffee
---------------------------------
initialize = ->
latlng = new google.maps.LatLng(-34.397, 150.644)
myOptions =
zoom: 8
center: latlng
mapTypeId: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions)
$ -> initialize()
./view/application.html.haml
------------------------
!!! 5
%html
%head
%title Solar Map
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tag
%meta{:content => "initial-scale=1.0, user-scalable=no", :name => "viewpoint"}/
= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false"
%body
= yield
./view/maps/index.html.haml
----------------------------
#map_canvas{:style => "width:100%; height:100%"}
Google Code
--------------
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=set_to_true_or_false">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment