Class: Jekyll::UJCommentsTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Jekyll::UJPowertools::VariableResolver
Defined in:
lib/tags/fake_comments.rb

Instance Method Summary collapse

Methods included from Jekyll::UJPowertools::VariableResolver

#is_quoted?, #parse_arguments, #parse_options, #resolve_input, #resolve_variable

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ UJCommentsTag

Returns a new instance of UJCommentsTag.



8
9
10
11
# File 'lib/tags/fake_comments.rb', line 8

def initialize(tag_name, markup, tokens)
  super
  @markup = markup.strip
end

Instance Method Details

#render(context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tags/fake_comments.rb', line 13

def render(context)
  # Get the content to analyze
  content = resolve_content(context)
  return '0' unless content
  
  # Strip HTML tags
  stripped_content = strip_html(content)
  
  # Count words
  words = count_words(stripped_content)
  
  # Generate comment count based on word count modulo 13
  comments = words % 13
  
  comments.to_s
end