Repository: yippee-fun/phlex (ruby)

Issue:
Rename `Phlex::Component` → `Phlex::View`
Phlex can be used to build layouts and pages as well as components. I think the word "component" it quite limiting. It refers to _part of something_ but not _the whole of something_.


Discussion:

Patch:
diff --git a/docs/components/callout.rb b/docs/components/callout.rb
--- a/docs/components/callout.rb
+++ b/docs/components/callout.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Callout < Phlex::Component
+	class Callout < Phlex::View
 		def template(&block)
 			div(class: "rounded bg-orange-50 text-sm p-5 border border-orange-100", &block)
 		end
diff --git a/docs/components/code_block.rb b/docs/components/code_block.rb
--- a/docs/components/code_block.rb
+++ b/docs/components/code_block.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class CodeBlock < Phlex::Component
+	class CodeBlock < Phlex::View
 		FORMATTER = Rouge::Formatters::HTML.new
 
 		def initialize(code, syntax:)
diff --git a/docs/components/example.rb b/docs/components/example.rb
--- a/docs/components/example.rb
+++ b/docs/components/example.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Example < Phlex::Component
+	class Example < Phlex::View
 		def initialize
 			@sandbox = Module.new
 		end
diff --git a/docs/components/heading.rb b/docs/components/heading.rb
--- a/docs/components/heading.rb
+++ b/docs/components/heading.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Heading < Phlex::Component
+	class Heading < Phlex::View
 		def template(&block)
 			h2(class: "text-xl font-bold mt-10 mb-5", &block)
 		end
diff --git a/docs/components/layout.rb b/docs/components/layout.rb
--- a/docs/components/layout.rb
+++ b/docs/components/layout.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Layout < Phlex::Component
+	class Layout < Phlex::View
 		register_element :style
 
 		def initialize(title:)
@@ -28,7 +28,7 @@ def template(&block)
 								ul do
 									li { a "Introduction", href: "/" }
 									li { a "Templates", href: "/templates" }
-									li { a "Components", href: "/components" }
+									li { a "Views", href: "/components" }
 									li { a "Rails integration", href: "/rails-integration" }
 									li { a "Source code", href: "https://github.com/joeldrapper/phlex" }
 								end
diff --git a/docs/components/markdown.rb b/docs/components/markdown.rb
--- a/docs/components/markdown.rb
+++ b/docs/components/markdown.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Markdown < Phlex::Component
+	class Markdown < Phlex::View
 		class Render < Redcarpet::Render::HTML
 			def header(text, level)
 				case level
diff --git a/docs/components/tabs.rb b/docs/components/tabs.rb
--- a/docs/components/tabs.rb
+++ b/docs/components/tabs.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Tabs < Phlex::Component
+	class Tabs < Phlex::View
 		def initialize
 			@index = 1
 		end
diff --git a/docs/components/tabs/tab.rb b/docs/components/tabs/tab.rb
--- a/docs/components/tabs/tab.rb
+++ b/docs/components/tabs/tab.rb
@@ -2,7 +2,7 @@
 
 module Components
 	class Tabs
-		class Tab < Phlex::Component
+		class Tab < Phlex::View
 			def initialize(name:, checked:)
 				@name = name
 				@checked = checked
diff --git a/docs/components/title.rb b/docs/components/title.rb
--- a/docs/components/title.rb
+++ b/docs/components/title.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Components
-	class Title < Phlex::Component
+	class Title < Phlex::View
 		def template(&block)
 			h1(class: "text-2xl font-bold my-5", &block)
 		end
diff --git a/docs/pages/application_page.rb b/docs/pages/application_page.rb
--- a/docs/pages/application_page.rb
+++ b/docs/pages/application_page.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Pages
-	class ApplicationPage < Phlex::Component
+	class ApplicationPage < Phlex::View
 		include ::Components
 	end
 end
diff --git a/docs/pages/rails_integration.rb b/docs/pages/rails_integration.rb
--- a/docs/pages/rails_integration.rb
+++ b/docs/pages/rails_integration.rb
@@ -18,7 +18,7 @@ def template
 					# app/views/card.rb
 
 					module Views
-						class Card < Phlex::Component
+						class Card < Phlex::View
 							def template
 							end
 						end
diff --git a/docs/pages/templates.rb b/docs/pages/templates.rb
--- a/docs/pages/templates.rb
+++ b/docs/pages/templates.rb
@@ -9,14 +9,14 @@ def template
 
 					Rather than use another langauge like ERB, HAML or Slim, Phlex provides a Ruby DSL for defining HTML templates.
 
-					You can create a component class by subclassing `Phlex::Component` and defining a method called `template`. Within the `template` method, you can compose HTML markup by calling the name of any [HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element).
+					You can create a component class by subclassing `Phlex::View` and defining a method called `template`. Within the `template` method, you can compose HTML markup by calling the name of any [HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element).
 
 					The first argument to an HTML element method is the _text content_ for that element. For example, here’s a component with an `<h1>` element that says “Hello World!”
 				MD
 
 				render Example.new do |e|
 					e.tab "heading.rb", <<~RUBY
-						class Heading < Phlex::Component
+						class Heading < Phlex::View
 							def template
 								h1 "Hello World!"
 							end
@@ -36,7 +36,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "heading.rb", <<~RUBY
-						class Heading < Phlex::Component
+						class Heading < Phlex::View
 							def template
 								h1 "Hello World!",
 									class: "text-xl font-bold",
@@ -54,7 +54,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								input type: "radio", name: "channel", id: "1", checked: true
 								input type: "radio", name: "channel", id: "2", checked: false
@@ -73,7 +73,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "nav.rb", <<~RUBY
-						class Nav < Phlex::Component
+						class Nav < Phlex::View
 							def template
 								nav do
 									ul do
@@ -97,7 +97,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "heading.rb", <<~RUBY
-						class Heading < Phlex::Component
+						class Heading < Phlex::View
 							def template
 								h1 { strong "Hello "; text "World!" }
 							end
@@ -115,7 +115,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "links.rb", <<~RUBY
-						class Links < Phlex::Component
+						class Links < Phlex::View
 							def template
 								a "Home", href: "/"
 								whitespace
@@ -143,7 +143,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "link.rb", <<~RUBY
-						class Link < Phlex::Component
+						class Link < Phlex::View
 							def initialize(text, to:, active:)
 								@text = text
 								@to = to
@@ -162,7 +162,7 @@ def active? = @active
 					RUBY
 
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								nav do
 									ul do
@@ -183,7 +183,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "link.rb", <<~RUBY
-						class Link < Phlex::Component
+						class Link < Phlex::View
 							def initialize(text, to:, active:)
 								@text = text
 								@to = to
@@ -202,7 +202,7 @@ def active? = @active
 					RUBY
 
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								nav do
 									ul do
@@ -225,7 +225,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								template_tag do
 									img src: "hidden.jpg", alt: "A hidden image."
diff --git a/docs/pages/components.rb b/docs/pages/views.rb
similarity index 89%
rename from docs/pages/components.rb
rename to docs/pages/views.rb
--- a/docs/pages/components.rb
+++ b/docs/pages/views.rb
@@ -1,11 +1,11 @@
 # frozen_string_literal: true
 
 module Pages
-	class Components < ApplicationPage
+	class Views < ApplicationPage
 		def template
 			render Layout.new(title: "Components in Phlex") do
 				render Markdown.new(<<~MD)
-					# Components
+					#  Views
 
 					## Yielding content
 
@@ -14,7 +14,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "card.rb", <<~RUBY
-						class Card < Phlex::Component
+						class Card < Phlex::View
 							def template(&)
 								article(class: "drop-shadow rounded p-5") {
 									h1 "Amazing content!"
@@ -35,7 +35,7 @@ def template(&)
 
 				render Example.new do |e|
 					e.tab "card.rb", <<~RUBY
-						class Card < Phlex::Component
+						class Card < Phlex::View
 							def template(&)
 								article(class: "drop-shadow rounded p-5", &)
 							end
@@ -53,7 +53,7 @@ def template(&)
 
 				render Example.new do |e|
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								render Card.new do
 									h1 "Hello"
@@ -63,7 +63,7 @@ def template
 					RUBY
 
 					e.tab "card.rb", <<~RUBY
-						class Card < Phlex::Component
+						class Card < Phlex::View
 							def template(&)
 								article(class: "drop-shadow rounded p-5", &)
 							end
@@ -79,7 +79,7 @@ def template(&)
 
 				render Example.new do |e|
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								render(Card.new) { "Hi" }
 							end
@@ -87,7 +87,7 @@ def template
 					RUBY
 
 					e.tab "card.rb", <<~RUBY
-						class Card < Phlex::Component
+						class Card < Phlex::View
 							def template(&)
 								article(class: "drop-shadow rounded p-5", &)
 							end
@@ -105,7 +105,7 @@ def template(&)
 
 				render Example.new do |e|
 					e.tab "hello.rb", <<~RUBY
-						class Hello < Phlex::Component
+						class Hello < Phlex::View
 							def initialize(name:)
 								@name = name
 							end
@@ -117,7 +117,7 @@ def template
 					RUBY
 
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								render Hello.new(name: "Joel")
 							end
@@ -137,7 +137,7 @@ def template
 
 				render Example.new do |e|
 					e.tab "status.rb", <<~RUBY
-						class Status < Phlex::Component
+						class Status < Phlex::View
 							def initialize(status:)
 								@status = status
 							end
@@ -160,7 +160,7 @@ def status_emoji
 					RUBY
 
 					e.tab "example.rb", <<~RUBY
-						class Example < Phlex::Component
+						class Example < Phlex::View
 							def template
 								render Status.new(status: :success)
 							end
diff --git a/fixtures/compilation/vcall.rb b/fixtures/compilation/vcall.rb
--- a/fixtures/compilation/vcall.rb
+++ b/fixtures/compilation/vcall.rb
@@ -3,19 +3,19 @@
 module Fixtures
 	module Compilation
 		module VCall
-			class WithStandardElement < Phlex::Component
+			class WithStandardElement < Phlex::View
 				def template
 					div
 				end
 			end
 
-			class WithVoidElement < Phlex::Component
+			class WithVoidElement < Phlex::View
 				def template
 					img
 				end
 			end
 
-			class WithAnotherMethodCall < Phlex::Component
+			class WithAnotherMethodCall < Phlex::View
 				def template
 					article
 					some_other_method
@@ -23,7 +23,7 @@ def template
 				end
 			end
 
-			class WithRedefinedTagMethod < Phlex::Component
+			class WithRedefinedTagMethod < Phlex::View
 				def template
 					title
 					article
diff --git a/fixtures/dummy/app/views/articles/form.rb b/fixtures/dummy/app/views/articles/form.rb
--- a/fixtures/dummy/app/views/articles/form.rb
+++ b/fixtures/dummy/app/views/articles/form.rb
@@ -2,7 +2,7 @@
 
 module Views
 	module Articles
-		class Form < Phlex::Component
+		class Form < Phlex::View
 			def template
 				form_with url: "test" do |f|
 					f.text_field :name
diff --git a/fixtures/dummy/app/views/card.rb b/fixtures/dummy/app/views/card.rb
--- a/fixtures/dummy/app/views/card.rb
+++ b/fixtures/dummy/app/views/card.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Views
-	class Card < Phlex::Component
+	class Card < Phlex::View
 		def template(&block)
 			article class: "drop-shadow p-5 rounded", &block
 		end
diff --git a/fixtures/dummy/app/views/heading.rb b/fixtures/dummy/app/views/heading.rb
--- a/fixtures/dummy/app/views/heading.rb
+++ b/fixtures/dummy/app/views/heading.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Views
-	class Heading < Phlex::Component
+	class Heading < Phlex::View
 		def template(&block)
 			h1(&block)
 		end
diff --git a/fixtures/layout.rb b/fixtures/layout.rb
--- a/fixtures/layout.rb
+++ b/fixtures/layout.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Example
-	class LayoutComponent < Phlex::Component
+	class LayoutComponent < Phlex::View
 		def initialize(title: "Example")
 			@title = title
 		end
diff --git a/fixtures/page.rb b/fixtures/page.rb
--- a/fixtures/page.rb
+++ b/fixtures/page.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 module Example
-	class Page < Phlex::Component
+	class Page < Phlex::View
 		def template
 			render LayoutComponent.new do
 				h1 "Hi"
diff --git a/fixtures/component_helper.rb b/fixtures/view_helper.rb
similarity index 50%
rename from fixtures/component_helper.rb
rename to fixtures/view_helper.rb
--- a/fixtures/component_helper.rb
+++ b/fixtures/view_helper.rb
@@ -1,16 +1,16 @@
 # frozen_string_literal: true
 
-module ComponentHelper
+module ViewHelper
 	def self.extended(parent)
 		parent.class_exec do
 			let(:output) { example.call }
-			let(:example) { component.new }
+			let(:example) { view.new }
 		end
 	end
 
-	def component(&block)
-		let :component do
-			Class.new(Phlex::Component, &block)
+	def view(&block)
+		let :view do
+			Class.new(Phlex::View, &block)
 		end
 	end
 end
diff --git a/lib/generators/phlex/component/component_generator.rb b/lib/generators/phlex/component/component_generator.rb
--- a/lib/generators/phlex/component/component_generator.rb
+++ b/lib/generators/phlex/component/component_generator.rb
@@ -5,7 +5,7 @@ module Generators
 		class ComponentGenerator < ::Rails::Generators::NamedBase
 			source_root File.expand_path("templates", __dir__)
 
-			def create_component
+			def create_view
 				template "component.rb.erb", File.join("app/views", class_path, "#{file_name}.rb")
 			end
 		end
diff --git a/lib/generators/phlex/component/templates/component.rb.erb b/lib/generators/phlex/component/templates/component.rb.erb
--- a/lib/generators/phlex/component/templates/component.rb.erb
+++ b/lib/generators/phlex/component/templates/component.rb.erb
@@ -1,6 +1,6 @@
 <% module_namespacing do -%>
 module Views
-  class <%= class_name %> < Phlex::Component
+  class <%= class_name %> < Phlex::View
     def template
     end
   end
diff --git a/lib/phlex.rb b/lib/phlex.rb
--- a/lib/phlex.rb
+++ b/lib/phlex.rb
@@ -14,11 +14,20 @@
 module Phlex
 	Error = Module.new
 	ArgumentError = Class.new(ArgumentError) { include Error }
+	NameError = Class.new(NameError) { include Error }
 
 	extend self
 
 	ATTRIBUTE_CACHE = {}
 
+	def const_missing(name)
+		if name == :Component
+			raise NameError, "👋 Phlex::Component is now Phlex::View"
+		else
+			super
+		end
+	end
+
 	def configuration
 		@configuration ||= Configuration.new
 	end
diff --git a/lib/phlex/compiler.rb b/lib/phlex/compiler.rb
--- a/lib/phlex/compiler.rb
+++ b/lib/phlex/compiler.rb
@@ -18,7 +18,7 @@ def redefined?(method_name)
 			prototype = @component.allocate
 
 			@component.instance_method(method_name).bind(prototype) !=
-				Phlex::Component.instance_method(method_name).bind(prototype)
+				Phlex::View.instance_method(method_name).bind(prototype)
 		end
 
 		def redefine(method)
diff --git a/lib/phlex/engine.rb b/lib/phlex/engine.rb
--- a/lib/phlex/engine.rb
+++ b/lib/phlex/engine.rb
@@ -5,7 +5,7 @@
 module Phlex
 	class Engine < ::Rails::Engine
 		initializer "phlex.tag_helpers" do
-			Phlex::Component.include(Phlex::Rails::TagHelpers)
+			Phlex::View.include(Phlex::Rails::TagHelpers)
 		end
 	end
 end
diff --git a/lib/phlex/renderable.rb b/lib/phlex/renderable.rb
--- a/lib/phlex/renderable.rb
+++ b/lib/phlex/renderable.rb
@@ -3,13 +3,13 @@
 module Phlex
 	module Renderable
 		def render(renderable, *args, **kwargs, &block)
-			if renderable.is_a?(Component)
+			if renderable.is_a?(View)
 				if block_given? && !block.binding.receiver.is_a?(Phlex::Block)
 					block = Phlex::Block.new(self, &block)
 				end
 
 				renderable.call(@_target, view_context: @_view_context, parent: self, &block)
-			elsif renderable.is_a?(Class) && renderable < Component
+			elsif renderable.is_a?(Class) && renderable < View
 				raise ArgumentError, "You tried to render the Phlex component class: #{renderable.name} but you probably meant to render an instance of that class instead."
 			else
 				@_target << @_view_context.render(renderable, *args, **kwargs, &block)
diff --git a/lib/phlex/component.rb b/lib/phlex/view.rb
similarity index 99%
rename from lib/phlex/component.rb
rename to lib/phlex/view.rb
--- a/lib/phlex/component.rb
+++ b/lib/phlex/view.rb
@@ -5,7 +5,7 @@
 end
 
 module Phlex
-	class Component
+	class View
 		extend HTML
 		include Renderable
 


Test patch:
diff --git a/fixtures/test_helper.rb b/fixtures/test_helper.rb
--- a/fixtures/test_helper.rb
+++ b/fixtures/test_helper.rb
@@ -10,4 +10,4 @@
 	config.autoload_paths << "#{root}/app"
 end
 
-require "component_helper"
+require "view_helper"
diff --git a/test/phlex/rails.rb b/test/phlex/rails.rb
--- a/test/phlex/rails.rb
+++ b/test/phlex/rails.rb
@@ -2,7 +2,7 @@
 
 require "test_helper"
 
-describe Phlex::Component do
+describe Phlex::View do
 	with "rendered in an ERB view" do
 		let(:output) { ArticlesController.render "index" }
 
diff --git a/test/phlex/rails/form_with.rb b/test/phlex/rails/form_with.rb
--- a/test/phlex/rails/form_with.rb
+++ b/test/phlex/rails/form_with.rb
@@ -2,7 +2,7 @@
 
 require "test_helper"
 
-describe Phlex::Component do
+describe Phlex::View do
 	let(:output) { ArticlesController.render "new" }
 
 	with "form_with" do
diff --git a/test/phlex/component/attributes.rb b/test/phlex/view/attributes.rb
similarity index 79%
rename from test/phlex/component/attributes.rb
rename to test/phlex/view/attributes.rb
--- a/test/phlex/component/attributes.rb
+++ b/test/phlex/view/attributes.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "hash attributes" do
-		component do
+		view do
 			def template
 				div data: { name: { first_name: "Joel" } }
 			end
@@ -19,17 +19,17 @@ def template
 
 	if RUBY_ENGINE == "ruby"
 		with "unique tag attributes" do
-			component do
+			view do
 				def template
 					div class: SecureRandom.hex
 				end
 			end
 
 			let :report do
-				component.new.call
+				view.new.call
 
 				MemoryProfiler.report do
-					2.times { component.new.call }
+					2.times { view.new.call }
 				end
 			end
 
diff --git a/test/phlex/component/call.rb b/test/phlex/view/call.rb
similarity index 78%
rename from test/phlex/component/call.rb
rename to test/phlex/view/call.rb
--- a/test/phlex/component/call.rb
+++ b/test/phlex/view/call.rb
@@ -2,10 +2,10 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
-	component do
+	view do
 		def template
 			text "Hi"
 		end
@@ -17,7 +17,7 @@ def template
 		end
 
 		with "a spent component" do
-			let(:example) { component.new.tap(&:call) }
+			let(:example) { view.new.tap(&:call) }
 
 			it "raises an ArgumentError" do
 				expect { example.call }.to raise_exception RuntimeError,
diff --git a/test/phlex/component/comment.rb b/test/phlex/view/comment.rb
similarity index 87%
rename from test/phlex/component/comment.rb
rename to test/phlex/view/comment.rb
--- a/test/phlex/component/comment.rb
+++ b/test/phlex/view/comment.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "simple comment" do
-		component do
+		view do
 			def template
 				comment "This is an HTML comment"
 			end
@@ -18,7 +18,7 @@ def template
 	end
 
 	with "empty comment" do
-		component do
+		view do
 			def template
 				comment
 			end
@@ -30,7 +30,7 @@ def template
 	end
 
 	with "number comment" do
-		component do
+		view do
 			def template
 				comment 1
 			end
@@ -42,7 +42,7 @@ def template
 	end
 
 	with "escaped comment" do
-		component do
+		view do
 			def template
 				comment "<b>Important</b>"
 			end
diff --git a/test/phlex/component/content.rb b/test/phlex/view/content.rb
similarity index 79%
rename from test/phlex/component/content.rb
rename to test/phlex/view/content.rb
--- a/test/phlex/component/content.rb
+++ b/test/phlex/view/content.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "content" do
-		component do
+		view do
 			def template(&block)
 				div do
 					content(&block)
diff --git a/test/phlex/component/custom_elements.rb b/test/phlex/view/custom_elements.rb
similarity index 85%
rename from test/phlex/component/custom_elements.rb
rename to test/phlex/view/custom_elements.rb
--- a/test/phlex/component/custom_elements.rb
+++ b/test/phlex/view/custom_elements.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "custom elements" do
-		component do
+		view do
 			register_element :trix_editor
 			register_element :trix_toolbar
 
diff --git a/test/phlex/component/doctype.rb b/test/phlex/view/doctype.rb
similarity index 80%
rename from test/phlex/component/doctype.rb
rename to test/phlex/view/doctype.rb
--- a/test/phlex/component/doctype.rb
+++ b/test/phlex/view/doctype.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "a doctype" do
-		component do
+		view do
 			def template
 				html do
 					head { doctype }
diff --git a/test/phlex/component/naughty_business.rb b/test/phlex/view/naughty_business.rb
similarity index 93%
rename from test/phlex/component/naughty_business.rb
rename to test/phlex/view/naughty_business.rb
--- a/test/phlex/component/naughty_business.rb
+++ b/test/phlex/view/naughty_business.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "naughty text" do
-		component do
+		view do
 			def template
 				text %("><script type="text/javascript" src="bad_script.js"></script>)
 			end
@@ -18,7 +18,7 @@ def template
 	end
 
 	with "naughty tag attribute values" do
-		component do
+		view do
 			def template
 				article id: %("><script type="text/javascript" src="bad_script.js"></script>)
 			end
@@ -30,7 +30,7 @@ def template
 	end
 
 	with "naughty javascript link protocol in href" do
-		component do
+		view do
 			def template
 				a "naughty link", href: "javascript:javascript:alert(1)"
 			end
@@ -45,7 +45,7 @@ def template
 		with "with naughty #{event_attribute} attribute" do
 			naughty_attributes = { event_attribute => "alert(1);" }
 
-			component do
+			view do
 				define_method :template do
 					send(:div, **naughty_attributes)
 				end
@@ -63,7 +63,7 @@ def template
 			naughty_attribute = "abc#{naughty_character}123"
 			naughty_attributes = { naughty_attribute => "alert(1);" }
 
-			component do
+			view do
 				define_method :template do
 					send(:div, **naughty_attributes)
 				end
diff --git a/test/phlex/component/numbers.rb b/test/phlex/view/numbers.rb
similarity index 84%
rename from test/phlex/component/numbers.rb
rename to test/phlex/view/numbers.rb
--- a/test/phlex/component/numbers.rb
+++ b/test/phlex/view/numbers.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "numbers" do
-		component do
+		view do
 			def template
 				span 1
 				span 2.0
@@ -19,7 +19,7 @@ def template
 	end
 
 	with "numbers in block" do
-		component do
+		view do
 			def template
 				span do
 					1
diff --git a/test/phlex/component/raw.rb b/test/phlex/view/raw.rb
similarity index 79%
rename from test/phlex/component/raw.rb
rename to test/phlex/view/raw.rb
--- a/test/phlex/component/raw.rb
+++ b/test/phlex/view/raw.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "raw content" do
-		component do
+		view do
 			def template
 				raw %(<h1 class="test">Hello</h1>)
 			end
diff --git a/test/phlex/component/renderable/format.rb b/test/phlex/view/renderable/format.rb
similarity index 70%
rename from test/phlex/component/renderable/format.rb
rename to test/phlex/view/renderable/format.rb
--- a/test/phlex/component/renderable/format.rb
+++ b/test/phlex/view/renderable/format.rb
@@ -2,10 +2,10 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
-	component
+	view
 
 	with "format" do
 		it "returns :html" do
diff --git a/test/phlex/component/renderable/render.rb b/test/phlex/view/renderable/render.rb
similarity index 76%
rename from test/phlex/component/renderable/render.rb
rename to test/phlex/view/renderable/render.rb
--- a/test/phlex/component/renderable/render.rb
+++ b/test/phlex/view/renderable/render.rb
@@ -2,14 +2,14 @@
 
 require "test_helper"
 
-Example = Class.new(Phlex::Component)
+Example = Class.new(Phlex::View)
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "#render" do
 		with "a component class" do
-			component do
+			view do
 				def template
 					render Example
 				end
@@ -22,16 +22,16 @@ def template
 		end
 
 		with "another component" do
-			other_component = Class.new Phlex::Component do
+			other_view = Class.new Phlex::View do
 				def template(&block)
 					div(&block)
 				end
 			end
 
 			with "markup" do
-				component do
+				view do
 					define_method :template do
-						render(other_component.new) do
+						render(other_view.new) do
 							h1 "Hi!"
 						end
 					end
@@ -43,9 +43,9 @@ def template(&block)
 			end
 
 			with "text" do
-				component do
+				view do
 					define_method :template do
-						render(other_component.new) { "Hello world!" }
+						render(other_view.new) { "Hello world!" }
 					end
 				end
 
diff --git a/test/phlex/component/tags.rb b/test/phlex/view/tags.rb
similarity index 92%
rename from test/phlex/component/tags.rb
rename to test/phlex/view/tags.rb
--- a/test/phlex/component/tags.rb
+++ b/test/phlex/view/tags.rb
@@ -2,12 +2,12 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	Phlex::HTML::STANDARD_ELEMENTS.each do |method_name, tag|
 		with "<#{method_name}> with text content and attributes" do
-			component do
+			view do
 				define_method :template do
 					send(method_name, "content", class: "class", id: "id", disabled: true, selected: false)
 				end
@@ -19,7 +19,7 @@
 		end
 
 		with "<#{method_name}> with block content and attributes" do
-			component do
+			view do
 				define_method :template do
 					send(method_name, class: "class", id: "id", disabled: true, selected: false) { h1 "Hello" }
 				end
@@ -31,7 +31,7 @@
 		end
 
 		with "<#{method_name}> with block text content and attributes" do
-			component do
+			view do
 				define_method :template do
 					send(method_name, class: "class", id: "id", disabled: true, selected: false) { "content" }
 				end
@@ -45,7 +45,7 @@
 
 	Phlex::HTML::VOID_ELEMENTS.each do |method_name, tag|
 		with "<#{method_name}> with attributes" do
-			component do
+			view do
 				define_method :template do
 					send(method_name, class: "class", id: "id", disabled: true, selected: false)
 				end
diff --git a/test/phlex/component/text.rb b/test/phlex/view/text.rb
similarity index 83%
rename from test/phlex/component/text.rb
rename to test/phlex/view/text.rb
--- a/test/phlex/component/text.rb
+++ b/test/phlex/view/text.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "text" do
-		component do
+		view do
 			def template
 				text "Hi"
 			end
@@ -18,7 +18,7 @@ def template
 	end
 
 	with "int as text" do
-		component do
+		view do
 			def template
 				text 1
 			end
@@ -30,7 +30,7 @@ def template
 	end
 
 	with "float as text" do
-		component do
+		view do
 			def template
 				text 2.0
 			end
diff --git a/test/phlex/component/tokens.rb b/test/phlex/view/tokens.rb
similarity index 89%
rename from test/phlex/component/tokens.rb
rename to test/phlex/view/tokens.rb
--- a/test/phlex/component/tokens.rb
+++ b/test/phlex/view/tokens.rb
@@ -2,12 +2,12 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "conditional classes" do
 		with "symbol conditionals" do
-			component do
+			view do
 				def template
 					a "Home", href: "/", **classes("a", "b", "c", active?: "active", primary?: "primary")
 				end
@@ -28,7 +28,7 @@ def primary?
 		end
 
 		with "proc conditionals" do
-			component do
+			view do
 				def template
 					a "Home", href: "/", **classes("a", "b", "c",
 						-> { true } => "true",
diff --git a/test/phlex/component/whitespace.rb b/test/phlex/view/whitespace.rb
similarity index 79%
rename from test/phlex/component/whitespace.rb
rename to test/phlex/view/whitespace.rb
--- a/test/phlex/component/whitespace.rb
+++ b/test/phlex/view/whitespace.rb
@@ -2,11 +2,11 @@
 
 require "test_helper"
 
-describe Phlex::Component do
-	extend ComponentHelper
+describe Phlex::View do
+	extend ViewHelper
 
 	with "whitespace" do
-		component do
+		view do
 			def template
 				a "Home"
 				whitespace