Class: JekyllChatgpt::MessageLabel
- Inherits:
-
Liquid::For
- Object
- Liquid::For
- JekyllChatgpt::MessageLabel
- Defined in:
- lib/jekyll-chatgpt.rb
Overview
Renders nested ‘label` tags to display a message deep inside a branching conversation
Instance Method Summary collapse
Instance Method Details
#render(context) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jekyll-chatgpt.rb', line 32 def render(context) = @variable_name conversation = context.evaluate(@collection_name) = conversation["mapping"] = .keys.filter do |id_candidate| id_candidate.start_with? end.first = [] = [] while = [["parent"]] .append(["id"]) if end res = "<a class=\"chatgpt-target\" href=\"\##{message_id}\">" res += .map do |path_id| "<label class=\"chatgpt-deep-label\" for=\"chatgpt-control-#{path_id}\">" end.join("") res += @for_block.render(context) res += .map { |_| "</label>" }.join("") res += "</a>" res end |