Sha256: 45e417fb580b11ff6c75d0a6130eaed5b9d1d21a54d5a8b49ac4af6dd1423fe6

Contents?: true

Size: 705 Bytes

Versions: 40

Compression:

Stored size: 705 Bytes

Contents

module Locomotive::Wagon

  class PullSnippetsCommand < PullBaseCommand

    def _pull
      locales.each do |locale|
        api_client.snippets.all(locale).each do |snippet|
          write_snippet(snippet, locale)
        end
      end
    end

    def write_snippet(snippet, locale = nil)
      if (template = snippet.template).present?
        _template = replace_asset_urls(template)
        write_to_file(snippet_filepath(snippet, locale), _template)
      end
    end

    private

    def snippet_filepath(snippet, locale)
      filename = locale == default_locale ? snippet.slug : "#{snippet.slug}.#{locale}"
      File.join('app', 'views', 'snippets', filename + '.liquid')
    end

  end

end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.2.0.alpha2 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.2.0.alpha1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.1.1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.1.0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.1.0.beta1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.5 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.4 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.3 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.2 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.0.rc0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-3.0.0.beta2 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.4.1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.4.0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.4.0.rc2 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.4.0.rc1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.3.0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.3.0.rc1 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.2.0 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb
locomotivecms_wagon-2.2.0.rc3 lib/locomotive/wagon/commands/pull_sub_commands/pull_snippets_command.rb