Class: Psd2html::PsConvertor::Block

Inherits:
Convertor
  • Object
show all
Defined in:
lib/psd2html/psconvertor/block.rb

Direct Known Subclasses

BlockLink

Constant Summary

Constants inherited from Convertor

Convertor::CSS_HASH_BASE, Convertor::CSS_TPL, Convertor::HTML_HASH_BASE, Convertor::HTML_TPL

Instance Attribute Summary

Attributes inherited from Convertor

#childrenConvertors, #index, #parentConvertor, #psNode

Instance Method Summary collapse

Methods inherited from Convertor

#css_map, #curleft, #curtop, #get_css_tpl, #guid, #initialize, #render_css, #render_html, #sync_css, #sync_html

Constructor Details

This class inherits a constructor from Psd2html::Convertor

Instance Method Details

#css_skeletonObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/psd2html/psconvertor/block.rb', line 5

def css_skeleton

cssRenderData = {
	"classname" => "block-#{guid}",
	"styles" => {
		"position"=> "absolute",
		"display" => "inline-block",
		"width" => "#{@psNode.width}px",
		"height" => "#{@psNode.height}px",
		"left" => curleft,
		"top" => curtop,
		"z-index" => "#{@psNode.depth}#{@parentConvertor.childrenConvertors.length - @index.to_i}"
	}
}
	cssRenderData = CSS_HASH_BASE.merge(cssRenderData)
end

#get_html_tplObject



21
22
23
# File 'lib/psd2html/psconvertor/block.rb', line 21

def get_html_tpl
	"<{{tag}} {{#attributes}} {{key}}=\"{{value}}\" {{/attributes}}><div style=\"position:relative;\">{{{content}}}</div></{{tag}}>"
end

#html_skeletonObject



24
25
26
27
28
29
30
31
32
# File 'lib/psd2html/psconvertor/block.rb', line 24

def html_skeleton
	htmlRenderData = {
		"attributes" => {
		"class" => "block-#{guid}"
	},
	"tag" => "div"
	}
	htmlRenderData = HTML_HASH_BASE.merge(htmlRenderData)
end