Method: IqRdf.rails_template

Defined in:
lib/iq_rdf/rails/iq_rdf.rb

.rails_template(template, source = nil) ⇒ Object

Copyright 2011 innoQ Deutschland GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/iq_rdf/rails/iq_rdf.rb', line 15

def IqRdf.rails_template(template, source = nil)
  source ||= template.source

  "  document = IqRdf::Document.new()\n  \#{source}\n  if params[:format].to_s == \"ttl\"\n    controller.response.headers[\"Content-Type\"] ||= 'text/turtle;charset=utf-8'\n    document.to_turtle\n  elsif  params[:format].to_s == \"nt\"\n    controller.response.headers[\"Content-Type\"] ||= 'text/plain;charset=utf-8'\n    document.to_ntriples\n  elsif params[:format].to_s == \"rdf\"\n    controller.response.headers[\"Content-Type\"] ||= 'application/xml+rdf;charset=utf-8'\n    document.to_xml\n  else # Default => turtle\n    controller.response.headers[\"Content-Type\"] ||= 'text/turtle;charset=utf-8'\n    document.to_turtle\n  end\n  EOV\nend\n"