Module: Trenni

Defined in:
lib/trenni/uri.rb,
lib/trenni/tag.rb,
lib/trenni/error.rb,
lib/trenni/query.rb,
lib/trenni/buffer.rb,
lib/trenni/markup.rb,
lib/trenni/builder.rb,
lib/trenni/strings.rb,
lib/trenni/version.rb,
lib/trenni/entities.rb,
lib/trenni/template.rb,
lib/trenni/reference.rb,
lib/trenni/fallback/query.rb,
lib/trenni/parse_delegate.rb,
lib/trenni/fallback/markup.rb,
lib/trenni/fallback/template.rb,
ext/trenni/trenni.c

Overview

Copyright, 2012, by Samuel G. D. Williams. <www.codeotaku.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Entities, Fallback, Markup, Native, Script, Strings Classes: Buffer, Builder, Error, FileBuffer, IOBuffer, Location, MarkupString, MarkupTemplate, ParseDelegate, ParseError, Query, Reference, Tag, Template, URI

Constant Summary collapse

Parsers =
Trenni::Fallback
VERSION =
"3.14.0"
OUT =

The output variable that will be used in templates:

:_out
BINDING =
binding

Class Method Summary collapse

Class Method Details

.Buffer(value) ⇒ Object



110
111
112
113
114
115
116
117
118
119
# File 'lib/trenni/buffer.rb', line 110

def self.Buffer(value)
	case value
	when String
		Buffer.new(value)
	when Buffer, FileBuffer, IOBuffer
		value
	else
		value.to_buffer
	end
end

.Reference(path = '', **parameters) ⇒ Object

Generate a URI from a path and user parameters. The path may contain a ‘#fragment` or `?query=parameters`.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/trenni/reference.rb', line 111

def self.Reference(path = '', **parameters)
	base, fragment = path.split('#', 2)
	path, query_string = base.split('?', 2)
	
	query = Query.new
	
	if query_string
		query.parse(Buffer.new(query_string))
	end
	
	query.update(parameters)
	
	Reference.new(path, query, fragment: fragment)
end

.URI(path = '', parameters = nil) ⇒ Object

Generate a URI from a path and user parameters. The path may contain a ‘#fragment` or `?query=parameters`.



111
112
113
114
115
116
# File 'lib/trenni/uri.rb', line 111

def self.URI(path = '', parameters = nil)
	base, fragment = path.split('#', 2)
	path, query_string = base.split('?', 2)
	
	URI.new(path, query_string, fragment, parameters)
end